make gamme pictures translatable
This commit is contained in:
parent
bf66d4d0d3
commit
cc5456213c
6 changed files with 33 additions and 16 deletions
|
|
@ -30,7 +30,9 @@ class Gamme extends Model
|
|||
'title',
|
||||
'slug',
|
||||
'text',
|
||||
'picture',
|
||||
'alt_text_picture',
|
||||
'banner',
|
||||
'alt_text_banner',
|
||||
];
|
||||
|
||||
|
|
@ -38,10 +40,10 @@ class Gamme extends Model
|
|||
protected static function boot()
|
||||
{
|
||||
static::creating(function (Gamme $gamme) {
|
||||
if ($gamme->picture) {
|
||||
if (is_a($gamme->picture,"SplFileInfo")) {
|
||||
$gamme->picture = Utils::storeImage($gamme->picture, $gamme->getTable());
|
||||
}
|
||||
if ($gamme->banner) {
|
||||
if (is_a($gamme->banner,"SplFileInfo")) {
|
||||
$gamme->banner = Utils::storeImage($gamme->banner, $gamme->getTable());
|
||||
}
|
||||
|
||||
|
|
@ -52,10 +54,10 @@ class Gamme extends Model
|
|||
});
|
||||
|
||||
static::updating(function (Gamme $gamme) {
|
||||
if ($gamme->picture) {
|
||||
if (is_a($gamme->picture,"SplFileInfo")) {
|
||||
$gamme->picture = Utils::storeImage($gamme->picture, $gamme->getTable());
|
||||
}
|
||||
if ($gamme->banner) {
|
||||
if (is_a($gamme->banner,"SplFileInfo")) {
|
||||
$gamme->banner = Utils::storeImage($gamme->banner, $gamme->getTable());
|
||||
}
|
||||
if ($gamme->parent_gamme_id === null) {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Lib\Utils;
|
||||
use App\Models\Gamme;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use SplFileInfo;
|
||||
use Illuminate\Support\Str;
|
||||
|
|
@ -17,15 +19,21 @@ class GammeFactory extends Factory
|
|||
{
|
||||
$title = $this->faker->text(10) . rand(1, 100);
|
||||
|
||||
$upload = new SplFileInfo(resource_path('assets/images/cookrange.jpg'));
|
||||
$picture = new Gamme();
|
||||
$imgpath = Utils::storeImage($upload, $picture->getTable());
|
||||
$upload = new SplFileInfo(resource_path('assets/images/entete_sous_gammes.jpg'));
|
||||
$bannerpath = Utils::storeImage($upload, $picture->getTable());
|
||||
|
||||
return [
|
||||
'parent_gamme_id' => null,
|
||||
'title' => $title,
|
||||
'slug' => Str::slug($title),
|
||||
'text' => $this->faker->text(5),
|
||||
'color' => $this->faker->hexColor(),
|
||||
'picture' => new SplFileInfo(resource_path('assets/images/cookrange.jpg')),
|
||||
'picture' => $imgpath,
|
||||
'alt_text_picture' => $this->faker->sentence(10),
|
||||
'banner' => new SplFileInfo(resource_path('assets/images/entete_sous_gammes.jpg')),
|
||||
'banner' => $bannerpath,
|
||||
'alt_text_banner' => $this->faker->sentence(10),
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,8 +99,8 @@ class ProductFactory extends Factory
|
|||
);
|
||||
|
||||
$upload = new SplFileInfo(resource_path('assets/images/product_sample_01.png'));
|
||||
$picto = new Product();
|
||||
$imgpath = Utils::storeImage($upload, $picto->getTable());
|
||||
$picture = new Product();
|
||||
$imgpath = Utils::storeImage($upload, $picture->getTable());
|
||||
|
||||
return [
|
||||
'name' => $name,
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Lib\Utils;
|
||||
use App\Models\Gamme;
|
||||
use App\Models\Product;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
|
@ -24,6 +25,12 @@ class GammesSeeder extends Seeder
|
|||
array_push($tabGammes, $gamme->color);
|
||||
});
|
||||
|
||||
$upload = new SplFileInfo(resource_path('assets/images/cookrange.jpg'));
|
||||
$picture = new Gamme();
|
||||
$imgpath = Utils::storeImage($upload, $picture->getTable());
|
||||
$upload = new SplFileInfo(resource_path('assets/images/entete_sous_gammes.jpg'));
|
||||
$bannerpath = Utils::storeImage($upload, $picture->getTable());
|
||||
|
||||
foreach ($tabGammes as $key => $value) {
|
||||
for ($i = 0; $i < 2; $i++) {
|
||||
$gamme = new Gamme();
|
||||
|
|
@ -33,9 +40,9 @@ class GammesSeeder extends Seeder
|
|||
$gamme->slug = Str::slug($gamme->title);
|
||||
$gamme->text = 'lorem ipsum set doloris' . $id . $i;
|
||||
$gamme->color = $value;
|
||||
$gamme->picture = new SplFileInfo(resource_path('assets/images/cookrange.jpg'));
|
||||
$gamme->picture = $imgpath;
|
||||
$gamme->alt_text_picture = 'lorem utus garis' . $id . $i;
|
||||
$gamme->banner = new SplFileInfo(resource_path('assets/images/entete_sous_gammes.jpg'));
|
||||
$gamme->banner = $bannerpath;
|
||||
$gamme->alt_text_banner = 'redus faeros' . $id . $i;
|
||||
$gamme->save();
|
||||
|
||||
|
|
@ -53,9 +60,9 @@ class GammesSeeder extends Seeder
|
|||
$gamme->slug = Str::slug($gamme->title);
|
||||
$gamme->text = 'lorem gurus et ipsum set doloris' . $id . $i;
|
||||
$gamme->color = '#ffa58' . rand(1, 9);
|
||||
$gamme->picture = new SplFileInfo(resource_path('assets/images/cookrange.jpg'));
|
||||
$gamme->picture = $imgpath;
|
||||
$gamme->alt_text_picture = 'lorem utus garis' . $id . $i;
|
||||
$gamme->banner = new SplFileInfo(resource_path('assets/images/cat_bckg.jpg'));
|
||||
$gamme->banner = $bannerpath;
|
||||
$gamme->alt_text_banner = 'redus faros' . $id . $i;
|
||||
$gamme->save();
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
<div class="form-group">
|
||||
<label for="picture">{{ __('Vignette') }} <small class="text-muted">- JPEG/PNG, 1Mo max. Dimensions {{ Config::get('bo.gamme_image_maxwidth') }} px par {{ Config::get('bo.gamme_image_maxheight') }} px</small></label><br/>
|
||||
<input type="file" id="picture" name="picture" accept="image/png, image/jpeg">
|
||||
@if ($gamme->picture !== null)
|
||||
@if (!empty($gamme->picture))
|
||||
<br/>
|
||||
<br/>
|
||||
<img src="{{$gamme->picture}}" alt="{{$gamme->alt_text_picture}}" style="max-height: 100px;">
|
||||
|
|
@ -26,7 +26,7 @@
|
|||
<div class="form-group">
|
||||
<label for="banner">{{ __('Bannière') }} <small class="text-muted">- JPEG/PNG, 2Mo max. Dimensions {{ Config::get('bo.gamme_banner_maxwidth') }} px par {{ Config::get('bo.gamme_banner_maxheight') }} px</small></label><br/>
|
||||
<input type="file" id="banner" name="banner" accept="image/png, image/jpeg">
|
||||
@if ($gamme->banner !== null)
|
||||
@if (!empty($gamme->banner))
|
||||
<br/>
|
||||
<br/>
|
||||
<img src="{{$gamme->banner}}" alt="{{$gamme->alt_text_banner}}" style="max-height: 100px;">
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
<td>{{$gamme->title}}</td>
|
||||
@endif
|
||||
<td>{{$gamme->text}}</td>
|
||||
<td><img src="{{ asset($gamme->picture) }}" height="50px"></td>
|
||||
<td>@if (!empty($gamme->picture))<img src="{{ asset($gamme->picture) }}" height="50px">@endif</td>
|
||||
<td><input type="color" class="form-control form-control-color" id="exampleColorInput" value="{{$gamme->color}}" disabled></td>
|
||||
<td>
|
||||
@if (isset($gamme->parentGamme))
|
||||
|
|
@ -50,4 +50,4 @@
|
|||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
@endsection
|
||||
@endsection
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue