diff --git a/app/Http/Controllers/Bo/PrizeController.php b/app/Http/Controllers/Bo/PrizeController.php index 4cf1504..ede76b3 100644 --- a/app/Http/Controllers/Bo/PrizeController.php +++ b/app/Http/Controllers/Bo/PrizeController.php @@ -38,14 +38,12 @@ class PrizeController extends Controller $prizeModels, $search, null, - 'label_one', - 'label_many', + 'label', ); } $searchFields = \sprintf( - '%s, %s ...', - Str::ucfirst(__('validation.custom.label_one')), - __('validation.custom.label_many'), + '%s ...', + Str::ucfirst(__('validation.custom.label')) ); /** Sort columns with a query */ diff --git a/app/Http/Controllers/Fo/EnterCodeController.php b/app/Http/Controllers/Fo/EnterCodeController.php index f753b9b..0b4da2d 100644 --- a/app/Http/Controllers/Fo/EnterCodeController.php +++ b/app/Http/Controllers/Fo/EnterCodeController.php @@ -154,7 +154,7 @@ class EnterCodeController extends Controller ], [ 'fieldName' => 'label_type_support', - 'fieldValue' => 'Gain du lot : ' . $instantWin->prize->label_one + 'fieldValue' => 'Gain du lot : ' . $instantWin->prize->label ] ] ]; diff --git a/app/Http/Requests/Bo/Prizes/StorePrizeRequest.php b/app/Http/Requests/Bo/Prizes/StorePrizeRequest.php index 97080e0..232581e 100644 --- a/app/Http/Requests/Bo/Prizes/StorePrizeRequest.php +++ b/app/Http/Requests/Bo/Prizes/StorePrizeRequest.php @@ -3,11 +3,14 @@ namespace App\Http\Requests\Bo\Prizes; use App\Models\Prize; +use App\Traits\Requests\HasPicture; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Gate; class StorePrizeRequest extends FormRequest { + use HasPicture; + /** * Determine if the user is authorized to make this request. * @@ -37,15 +40,22 @@ class StorePrizeRequest extends FormRequest */ public function rules() { - return [ - 'label_one' => 'required|string|min:3|max:255', - 'label_many' => 'required|string|min:3|max:255', + $rules = [ + 'label' => 'required|string|min:3|max:255', + 'picture_alt' => 'required|string|between:3,255', + 'picture_title' => 'required|string|between:3,255', 'arg_title' => 'required|string|min:3|max:255', 'arg_subtitle' => 'required|string|min:3|max:255', 'arg_content' => 'required|string|min:15', 'quantity' => 'required|numeric|min:1', 'pdf_winning_proof' => 'nullable|file|mimes:pdf', ]; + $width = config('theme.models.prizes.picture_max_width'); + $height = config('theme.models.prizes.picture_max_height'); + return \array_merge( + $rules, + $this->pictureRules('picture', $width, $height, $width, $height), + ); } /** @@ -56,8 +66,10 @@ class StorePrizeRequest extends FormRequest public function attributes(): array { return [ - 'label_one' => trans('validation.custom.label_one'), - 'label_many' => trans('validation.custom.label_many'), + 'label' => trans('validation.custom.label'), + 'picture' => trans('validation.custom.picture'), + 'picture_alt' => trans('validation.custom.picture_alt'), + 'picture_title' => trans('validation.custom.picture_title'), 'arg_title' => trans('validation.attributes.title'), 'arg_subtitle' => trans('validation.custom.subtitle'), 'arg_content' => trans('validation.attributes.content'), diff --git a/app/Mail/PrizeWon.php b/app/Mail/PrizeWon.php index 0a3da33..fd39ae2 100644 --- a/app/Mail/PrizeWon.php +++ b/app/Mail/PrizeWon.php @@ -49,7 +49,7 @@ class PrizeWon extends Mailable implements ShouldQueue return $this->subject(sprintf( 'Félicitations %s, vous avez remporté 1 %s !', $this->user->firstname, - $this->prize->label_one + $this->prize->label )) ->view('front.basic.prize-mail') ->with(['user' => $this->user, 'prize' => $this->prize, 'settings' => $this->settings]); diff --git a/app/Models/Prize.php b/app/Models/Prize.php index f5639c2..5ac954a 100644 --- a/app/Models/Prize.php +++ b/app/Models/Prize.php @@ -11,8 +11,10 @@ use Illuminate\Validation\ValidationException; /** * Prize. * - * @property string $label_one Singular label - * @property string $label_many Plural label + * @property string $label Label + * @property string $picture Path of the picture + * @property string $picture_alt Alt text for the picture + * @property string $picture_title Title text for the picture * @property string $arg_title Description title * @property string $arg_subtitle Description subtitle * @property string $arg_content Description content @@ -21,9 +23,6 @@ use Illuminate\Validation\ValidationException; * @property-read \Illuminate\Support\Carbon $created_at Creation Date. * @property-read \Illuminate\Support\Carbon $updated_at Last update Date. * - * @method protected static function booted() The "booted" method of the model. - * @method private static function manageFields($model) Manage model fields. - * * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\InstantWin[] $instantWins * Associated instantWins. */ @@ -37,8 +36,10 @@ class Prize extends Model * @var array */ protected $fillable = [ - 'label_one', - 'label_many', + 'label', + 'picture', + 'picture_alt', + 'picture_title', 'arg_title', 'arg_subtitle', 'arg_content', @@ -64,6 +65,7 @@ class Prize extends Model }); static::updated(function (self $model) { self::removeCached(); + FileStorageHelper::removeOldFile($model, 'picture'); FileStorageHelper::removeOldFile($model, 'pdf_winning_proof'); }); static::deleting(function (self $model) { @@ -77,6 +79,7 @@ class Prize extends Model }); static::deleted(function (self $model) { self::removeCached(); + FileStorageHelper::removeFile($model, 'picture'); FileStorageHelper::removeFile($model, 'pdf_winning_proof'); }); } @@ -86,15 +89,16 @@ class Prize extends Model /** * Common methods function. * - * @param Model $model + * @param \Illuminate\Database\Eloquent\Model $model * @return void */ private static function manageFields(Model $model) { + $model->picture = FileStorageHelper::storeFile($model, $model->picture, true); $model->pdf_winning_proof = FileStorageHelper::storeFile($model, $model->pdf_winning_proof, true); } - // * RELATIONS + // * RELATIONSHIPS /** * HasMany InstantWin relation diff --git a/app/Models/Product.php b/app/Models/Product.php index e272a88..6a5ed54 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -10,14 +10,13 @@ use Illuminate\Database\Eloquent\Model; /** * Product. * - * @property string $name Name - * @property string $picture Path of the picture - * @property integer $code_ean Ean code - * @property-read \Illuminate\Support\Carbon $created_at Creation Date. - * @property-read \Illuminate\Support\Carbon $updated_at Last update Date. - * - * @method protected static function booted() The "booted" method of the model. - * @method private static function manageFields($model) Manage model fields. + * @property string $name Name + * @property string $picture Path of the picture + * @property string $picture_alt Alt text for the picture + * @property string $picture_title Title text for the picture + * @property integer $code_ean Ean code + * @property-read \Illuminate\Support\Carbon $created_at Creation Date. + * @property-read \Illuminate\Support\Carbon $updated_at Last update Date. * * @property-read \App\Models\Range[] $range Associated range. * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Participation[] $participations @@ -71,9 +70,9 @@ class Product extends Model // * METHODS /** - * Undocumented function + * Common methods function. * - * @param Model $model + * @param \Illuminate\Database\Eloquent\Model $model * @return void */ private static function manageFields(Model $model) @@ -81,6 +80,8 @@ class Product extends Model $model->picture = FileStorageHelper::storeFile($model, $model->picture, true); } + // * RELATIONSHIPS + /** * Range relation * diff --git a/app/Models/Range.php b/app/Models/Range.php index e87baea..1ace3da 100644 --- a/app/Models/Range.php +++ b/app/Models/Range.php @@ -14,9 +14,6 @@ use Illuminate\Database\Eloquent\Model; * @property-read \Illuminate\Support\Carbon $created_at Creation Date. * @property-read \Illuminate\Support\Carbon $updated_at Last update Date. * - * @method protected static function booted() The "booted" method of the model. - * @method private static function manageFields($model) Manage model fields. - * * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Product[] $products * Associated products. */ @@ -60,9 +57,9 @@ class Range extends Model // * METHODS /** - * Undocumented function + * Common methods function. * - * @param Model $model + * @param \Illuminate\Database\Eloquent\Model $model * @return void */ private static function manageFields(Model $model) @@ -70,6 +67,8 @@ class Range extends Model $model->picture = FileStorageHelper::storeFile($model, $model->picture, true); } + // * RELATIONSHIPS + /** * Product relation * diff --git a/composer.json b/composer.json index 39cf02c..9edff3a 100644 --- a/composer.json +++ b/composer.json @@ -16,6 +16,7 @@ "axlon/laravel-postal-code-validation": "^3.4", "diglactic/laravel-breadcrumbs": "^8.0", "guzzlehttp/guzzle": "^7.2", + "kwaadpepper/image-resizer": "^2.1", "kwaadpepper/serial-int-caster": "^1.1", "laravel/framework": "^10.0", "laravel/tinker": "^2.8", diff --git a/composer.lock b/composer.lock index 610bc29..fa22656 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "5abaeeb6a418b44840fbe2581492f5d8", + "content-hash": "6e9302579912a55a9da2af836c6d2e94", "packages": [ { "name": "axlon/laravel-postal-code-validation", @@ -1348,6 +1348,157 @@ ], "time": "2023-08-27T10:19:19+00:00" }, + { + "name": "intervention/image", + "version": "2.7.2", + "source": { + "type": "git", + "url": "https://github.com/Intervention/image.git", + "reference": "04be355f8d6734c826045d02a1079ad658322dad" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Intervention/image/zipball/04be355f8d6734c826045d02a1079ad658322dad", + "reference": "04be355f8d6734c826045d02a1079ad658322dad", + "shasum": "" + }, + "require": { + "ext-fileinfo": "*", + "guzzlehttp/psr7": "~1.1 || ^2.0", + "php": ">=5.4.0" + }, + "require-dev": { + "mockery/mockery": "~0.9.2", + "phpunit/phpunit": "^4.8 || ^5.7 || ^7.5.15" + }, + "suggest": { + "ext-gd": "to use GD library based image processing.", + "ext-imagick": "to use Imagick based image processing.", + "intervention/imagecache": "Caching extension for the Intervention Image library" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + }, + "laravel": { + "providers": [ + "Intervention\\Image\\ImageServiceProvider" + ], + "aliases": { + "Image": "Intervention\\Image\\Facades\\Image" + } + } + }, + "autoload": { + "psr-4": { + "Intervention\\Image\\": "src/Intervention/Image" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Oliver Vogel", + "email": "oliver@intervention.io", + "homepage": "https://intervention.io/" + } + ], + "description": "Image handling and manipulation library with support for Laravel integration", + "homepage": "http://image.intervention.io/", + "keywords": [ + "gd", + "image", + "imagick", + "laravel", + "thumbnail", + "watermark" + ], + "support": { + "issues": "https://github.com/Intervention/image/issues", + "source": "https://github.com/Intervention/image/tree/2.7.2" + }, + "funding": [ + { + "url": "https://paypal.me/interventionio", + "type": "custom" + }, + { + "url": "https://github.com/Intervention", + "type": "github" + } + ], + "time": "2022-05-21T17:30:32+00:00" + }, + { + "name": "intervention/imagecache", + "version": "2.6.0", + "source": { + "type": "git", + "url": "https://github.com/Intervention/imagecache.git", + "reference": "86136575a62d3634b51f196a998fce4a583b49bb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Intervention/imagecache/zipball/86136575a62d3634b51f196a998fce4a583b49bb", + "reference": "86136575a62d3634b51f196a998fce4a583b49bb", + "shasum": "" + }, + "require": { + "illuminate/cache": "^5.5|~6|~7|~8|~9|~10", + "illuminate/filesystem": "^5.5|~6|~7|~8|~9|~10", + "intervention/image": "~2.2", + "nesbot/carbon": "^2.39", + "opis/closure": "^3.5", + "php": "~7.2|~8" + }, + "require-dev": { + "phpunit/phpunit": "^8.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Intervention\\Image\\": "src/Intervention/Image" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Oliver Vogel", + "email": "oliver@intervention.io", + "homepage": "http://intervention.io/" + } + ], + "description": "Caching extension for the Intervention Image Class", + "homepage": "https://image.intervention.io", + "keywords": [ + "cache", + "gd", + "image", + "imagick", + "laravel" + ], + "support": { + "issues": "https://github.com/Intervention/imagecache/issues", + "source": "https://github.com/Intervention/imagecache/tree/2.6.0" + }, + "funding": [ + { + "url": "https://paypal.me/interventionio", + "type": "custom" + }, + { + "url": "https://github.com/Intervention", + "type": "github" + } + ], + "time": "2023-02-25T19:40:47+00:00" + }, { "name": "jean85/pretty-package-versions", "version": "2.0.5", @@ -1467,6 +1618,66 @@ }, "time": "2022-07-28T15:18:54+00:00" }, + { + "name": "kwaadpepper/image-resizer", + "version": "2.1.0", + "source": { + "type": "git", + "url": "https://github.com/Kwaadpepper/image-resizer.git", + "reference": "2a14ad153b34916f437af50549bad47c018902df" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Kwaadpepper/image-resizer/zipball/2a14ad153b34916f437af50549bad47c018902df", + "reference": "2a14ad153b34916f437af50549bad47c018902df", + "shasum": "" + }, + "require": { + "illuminate/support": "~10", + "intervention/image": "^2.7.2", + "intervention/imagecache": "^2.6", + "laravel/framework": "~10" + }, + "require-dev": { + "slevomat/coding-standard": "^8.11" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Kwaadpepper\\ImageResizer\\ImageResizerServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Kwaadpepper\\ImageResizer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jérémy Munsch", + "email": "github@jeremydev.ovh", + "homepage": "https://jeremydev.ovh" + } + ], + "description": "Resize images on the fly and cache them", + "homepage": "https://github.com/kwaadpepper/image-resizer", + "keywords": [ + "images", + "laravel", + "resize" + ], + "support": { + "issues": "https://github.com/Kwaadpepper/image-resizer/issues", + "source": "https://github.com/Kwaadpepper/image-resizer/tree/2.1.0" + }, + "time": "2023-06-08T12:07:24+00:00" + }, { "name": "kwaadpepper/serial-int-caster", "version": "1.1.0", @@ -3133,6 +3344,71 @@ ], "time": "2023-11-13T09:31:12+00:00" }, + { + "name": "opis/closure", + "version": "3.6.3", + "source": { + "type": "git", + "url": "https://github.com/opis/closure.git", + "reference": "3d81e4309d2a927abbe66df935f4bb60082805ad" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/opis/closure/zipball/3d81e4309d2a927abbe66df935f4bb60082805ad", + "reference": "3d81e4309d2a927abbe66df935f4bb60082805ad", + "shasum": "" + }, + "require": { + "php": "^5.4 || ^7.0 || ^8.0" + }, + "require-dev": { + "jeremeamia/superclosure": "^2.0", + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.6.x-dev" + } + }, + "autoload": { + "files": [ + "functions.php" + ], + "psr-4": { + "Opis\\Closure\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marius Sarca", + "email": "marius.sarca@gmail.com" + }, + { + "name": "Sorin Sarca", + "email": "sarca_sorin@hotmail.com" + } + ], + "description": "A library that can be used to serialize closures (anonymous functions) and arbitrary objects.", + "homepage": "https://opis.io/closure", + "keywords": [ + "anonymous functions", + "closure", + "function", + "serializable", + "serialization", + "serialize" + ], + "support": { + "issues": "https://github.com/opis/closure/issues", + "source": "https://github.com/opis/closure/tree/3.6.3" + }, + "time": "2022-01-27T09:35:39+00:00" + }, { "name": "phpoption/phpoption", "version": "1.9.2", diff --git a/config/image-resizer.php b/config/image-resizer.php new file mode 100644 index 0000000..42c95ff --- /dev/null +++ b/config/image-resizer.php @@ -0,0 +1,64 @@ + 'imagick', + + /** + * The cache driver to use as defined + * in config/cache of your app + */ + 'cache' => 'file', + + /** + * The path where to store image in cache + */ + 'cachePath' => 'cache/images', + + /** + * Image cache life time + * This is given in minutes + * Here the cache for images is + * one hour + */ + 'lifetime' => 60, + + /** + * Format can specifiy to which format save the image + * JPEG PNG GIF TIF BMP ICO PSD WebP + * GD ✔️ ✔️ ✔️ - - - - ✔️ * + * Imagick ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ * + * For WebP support GD driver must be used with PHP 5 >= 5.5.0 or PHP 7 + * in order to use imagewebp(). If Imagick is used, it must be compiled + * with libwebp for WebP support. + * resize => will resize the image (boolean) + * fit => Combine cropping and resizing to format image in a smart way (boolean) + * keepRatio => will keep image ratio wile resizing (boolean) + * trim => boolean to trim the image using border color + * inCanvas => to make sure image boundarie is respected + * format => select tha wantd ouput form, yan can just convert images if you want + * example : + * 'small' => [ + * 'height' => 500, + * 'width' => 250, + * 'inCanvas' => true, + * 'trim' => ['transparent', null, 10] + * ], + * 'smallWebp' => [ + * 'height' => 500, + * 'width' => 250, + * 'inCanvas' => true, + * 'format' => 'webp' + * ], + * 'justconvertImage' => [ + * 'format' => 'webp' + * ] + */ + 'templates' => array_replace_recursive( + [], + (require(resource_path('theme/mounted/theme.config.php')))['resizes'], + ) +]; diff --git a/config/theme.php b/config/theme.php index a7464ff..9ccac46 100644 --- a/config/theme.php +++ b/config/theme.php @@ -4,6 +4,10 @@ return array_replace_recursive( [ 'name' => 'base', 'models' => [ + 'prizes' => [ + 'picture_max_width' => 560, + 'picture_max_height' => 700, + ], 'products' => [ 'picture_max_width' => 550, 'picture_max_height' => 550, @@ -13,6 +17,38 @@ return array_replace_recursive( 'picture_max_height' => 355, ], ], + /** + * Format can specifiy to which format save the image + * JPEG PNG GIF TIF BMP ICO PSD WebP + * GD ✔️ ✔️ ✔️ - - - - ✔️ * + * Imagick ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ * + * For WebP support GD driver must be used with PHP 5 >= 5.5.0 or PHP 7 + * in order to use imagewebp(). If Imagick is used, it must be compiled + * with libwebp for WebP support. + * resize => will resize the image (boolean) + * fit => Combine cropping and resizing to format image in a smart way (boolean) + * keepRatio => will keep image ratio wile resizing (boolean) + * trim => boolean to trim the image using border color + * inCanvas => to make sure image boundarie is respected + * format => select tha wantd ouput form, yan can just convert images if you want + * example : + * 'small' => [ + * 'height' => 500, + * 'width' => 250, + * 'inCanvas' => true, + * 'trim' => ['transparent', null, 10] + * ], + * 'smallWebp' => [ + * 'height' => 500, + * 'width' => 250, + * 'inCanvas' => true, + * 'format' => 'webp' + * ], + * 'justconvertImage' => [ + * 'format' => 'webp' + * ] + */ + 'resizes' => [] ], require(resource_path('theme/mounted/theme.config.php')), ); diff --git a/database/factories/assets/prizes/lot-1.png b/database/factories/assets/prizes/lot-1.png new file mode 100644 index 0000000..7640414 Binary files /dev/null and b/database/factories/assets/prizes/lot-1.png differ diff --git a/database/factories/assets/prizes/lot-2.png b/database/factories/assets/prizes/lot-2.png new file mode 100644 index 0000000..fe6c982 Binary files /dev/null and b/database/factories/assets/prizes/lot-2.png differ diff --git a/database/migrations/2020_10_29_091811_create_prizes.php b/database/migrations/2020_10_29_091811_create_prizes.php index b419803..a5388df 100644 --- a/database/migrations/2020_10_29_091811_create_prizes.php +++ b/database/migrations/2020_10_29_091811_create_prizes.php @@ -15,8 +15,12 @@ class CreatePrizes extends Migration { Schema::create('prizes', function (Blueprint $table) { $table->id(); - $table->string('label_one')->comment('Libellé au singulier'); - $table->string('label_many')->comment('Libellé au pluriel'); + $table->string('label')->comment('Libellé'); + + $table->string('picture')->comment('Image du lot'); + $table->string('picture_alt')->comment('Attribut alt de l\'image du lot'); + $table->string('picture_title')->comment('Attribut title de l\'image du lot'); + $table->string('arg_title')->comment('Tire argumentaire'); $table->string('arg_subtitle')->comment('Sous-titre argumentaire'); $table->text('arg_content')->comment('Contenu argumentaire'); diff --git a/database/seeders/Development/PrizeSeeder.php b/database/seeders/Development/PrizeSeeder.php index bd7f1bc..2a9fa59 100644 --- a/database/seeders/Development/PrizeSeeder.php +++ b/database/seeders/Development/PrizeSeeder.php @@ -2,6 +2,7 @@ namespace Database\Seeders\Development; +use App\Lib\Helpers\FileStorageHelper; use App\Models\Prize; use Illuminate\Database\Seeder; use Illuminate\Support\Facades\DB; @@ -24,21 +25,37 @@ class PrizeSeeder extends Seeder File::deleteDirectory(\storage_path('app/public/modelfiles/prizes')); $prize = new Prize(); - $prize->label_one = 'Lot 1'; - $prize->label_many = 'Lots 1'; - $prize->arg_title = 'Titre Lot 1'; - $prize->arg_subtitle = 'Sous-titre Lot 1'; - $prize->arg_content = 'Argumentaire du lot 1'; - $prize->quantity = 1; - $prize->save(); + $prize->label = 'Wonderbox Sportives et aventurières'; + $prize->arg_title = 'Wonderbox Sportives et aventurières'; + $prize->arg_subtitle = '1 activité pour 2 à 6 personnes'; + // phpcs:ignore Generic.Files.LineLength.TooLong + $prize->arg_content = '1640 activités en famille : cinéma, visite d’un zoo ou d’un château, spectacle au théâtre, cirque, balade en bateau, randonnée équestre, atelier culinaire… Les petits et les grands vont se régaler : sortie à l’aquarium de Paris pour faire connaissance avec ses 10 000 pensionnaires, atelier culinaire pour savourer une bonne dose de bonheur, découverte du bassin de la Villette en bateau électrique, rencontre avec le nouveau monde de Mini World Lyon…'; + $prize->picture = FileStorageHelper::storeFile( + new Prize(), + new \SplFileInfo( + \resource_path('../database/factories/assets/prizes/lot-1.png') + ) + ); + $prize->picture_title = 'Wonderbox Sportives et aventurières'; + $prize->picture_alt = 'Un coffret cadeau avec des personnes faisant du rift sur un bateau gonflable.'; + $prize->quantity = 1; + $prize->saveOrFail(); $prize = new Prize(); - $prize->label_one = 'Lot 2'; - $prize->label_many = 'Lots 2'; - $prize->arg_title = 'Titre Lot 2'; - $prize->arg_subtitle = 'Sous-titre Lot 2'; - $prize->arg_content = 'Argumentaire du lot 2'; - $prize->quantity = 2; - $prize->save(); + $prize->label = 'Wonderbox Happy Day'; + $prize->arg_title = 'Wonderbox Happy Day'; + $prize->arg_subtitle = '1 activité pour 1 à 2 personnes'; + // phpcs:ignore Generic.Files.LineLength.TooLong + $prize->arg_content = 'Plus de 2500 activités : laser game, bowling, balade en canoë, cinéma, repas, dégustation de macarons… Besoin d’une super activité pour déconnecter ? Soyez prêts, vous allez adorer cette journée : parties de bowling endiablées à Châlons-en-Champagne, séance de Taï Chi ou de Wing Chung à Bordeaux ou pizza à déguster face à Notre-Dame de Paris… Voici tout ce dont vous avez besoin pour apprécier un Happy Day !'; + $prize->picture = FileStorageHelper::storeFile( + new Prize(), + new \SplFileInfo( + \resource_path('../database/factories/assets/prizes/lot-2.png') + ) + ); + $prize->picture_title = 'Wonderbox Happy Day'; + $prize->picture_alt = 'Un coffret cadeau avec une femme faisant du canöe en mer.'; + $prize->quantity = 2; + $prize->saveOrFail(); } } diff --git a/resources/lang/fr/validation.php b/resources/lang/fr/validation.php index b7a4b46..d9e7171 100644 --- a/resources/lang/fr/validation.php +++ b/resources/lang/fr/validation.php @@ -244,8 +244,7 @@ return [ 'answer' => 'réponse', 'theme' => 'thème', 'file_name' => 'nom du fichier', - 'label_one' => 'libellé au singulier', - 'label_many' => 'libellé au pluriel', + 'label' => 'libellé', 'arg' => 'argumentaire', 'subtitle' => 'sous-titre', 'quantity' => 'quantité', diff --git a/resources/views/layouts/re7-offcanvas.blade.php b/resources/views/layouts/re7-offcanvas.blade.php index 200d77e..3b7a62a 100644 --- a/resources/views/layouts/re7-offcanvas.blade.php +++ b/resources/views/layouts/re7-offcanvas.blade.php @@ -22,10 +22,10 @@ {{-- WON PRIZE X --}} - {{ __('Lot :name', ['name' => $prize->label_one]) }} + {{ __('Lot :name', ['name' => $prize->label]) }} @endforeach diff --git a/resources/views/pages/prizes/form-inputs.blade.php b/resources/views/pages/prizes/form-inputs.blade.php index e962303..81cf1d1 100644 --- a/resources/views/pages/prizes/form-inputs.blade.php +++ b/resources/views/pages/prizes/form-inputs.blade.php @@ -1,17 +1,17 @@
- {{-- LABEL_ONE --}} + {{-- LABEL --}}
- {{ Str::ucfirst(__('validation.custom.label_one')) }} + {{ Str::ucfirst(__('validation.custom.label')) }}
@include('back::partials.inputs.varchar', [ 'id' => 'prizeLabelOne', 'label' => __(':field', [ - 'field' => Str::ucfirst(__('validation.custom.label_one')), + 'field' => Str::ucfirst(__('validation.custom.label')), ]), 'hasWordCounter' => true, - 'name' => 'label_one', + 'name' => 'label', 'required' => true, 'model' => $prizeModel ?? null, 'helper' => __('validation.between.string', [ @@ -22,7 +22,7 @@ 'max' => 255, ]), 'placeholder' => __(':field du :model', [ - 'field' => Str::ucfirst(__('validation.custom.label_one')), + 'field' => Str::ucfirst(__('validation.custom.label')), 'model' => Str::singular(__('models.classes.prize')), ]), ]) @@ -30,32 +30,75 @@
- {{-- LABEL_MANY --}} -
+ {{-- PICTURE --}} +
- {{ Str::ucfirst(__('validation.custom.label_many')) }} -
-
+ {{ Str::ucfirst(__('validation.attributes.image')) }} +
+ {{-- PICTURE_ALT --}} +
@include('back::partials.inputs.varchar', [ - 'id' => 'prizeLabelMany', - 'label' => __(':field', [ - 'field' => Str::ucfirst(__('validation.custom.label_many')), + 'id' => 'prizePictureAlt', + 'label' => __(':field1 :inter1:field2 :inter2:model', [ + 'field1' => Str::ucfirst(__('validation.custom.attribute_alt')), + 'inter1' => __('validation.custom.of_the.vowel'), + 'field2' => __('validation.attributes.image'), + 'inter2' => __('validation.custom.of_the.male'), + 'model' => __('models.classes.prize'), ]), 'hasWordCounter' => true, - 'name' => 'label_many', - 'required' => true, + 'name' => 'picture_alt', + 'required' => false, 'model' => $prizeModel ?? null, - 'helper' => __('validation.between.string', [ - 'attribute' => __(':field', [ - 'field' => Str::ucfirst(__('validation.attributes.name')), - ]), - 'min' => 3, - 'max' => 255, + 'helper' => __('crud.minicrud.picture_alt_helper'), + 'placeholder' => __(':field1 :inter1:field2 :inter2:model', [ + 'field1' => Str::ucfirst(__('validation.custom.attribute_alt')), + 'inter1' => __('validation.custom.of_the.vowel'), + 'field2' => __('validation.attributes.image'), + 'inter2' => __('validation.custom.of_the.male'), + 'model' => __('models.classes.prize'), ]), - 'placeholder' => __(':field du :model', [ - 'field' => Str::ucfirst(__('validation.custom.label_many')), - 'model' => Str::singular(__('models.classes.prize')), + ]) +
+ {{-- PICTURE_TITLE --}} +
+ @include('back::.partials.inputs.varchar', [ + 'id' => 'productPictureTitle', + 'label' => __(':field1 :inter1:field2 :inter2:model', [ + 'field1' => Str::ucfirst(__('validation.custom.attribute_title')), + 'inter1' => __('validation.custom.of_the.vowel'), + 'field2' => __('validation.attributes.image'), + 'inter2' => __('validation.custom.of_the.male'), + 'model' => __('models.classes.prize'), ]), + 'hasWordCounter' => true, + 'name' => 'picture_title', + 'required' => false, + 'model' => $prizeModel ?? null, + 'helper' => __('crud.minicrud.picture_title_helper'), + 'placeholder' => __(':field1 :inter1:field2 :inter2:model', [ + 'field1' => Str::ucfirst(__('validation.custom.attribute_title')), + 'inter1' => __('validation.custom.of_the.vowel'), + 'field2' => __('validation.attributes.image'), + 'inter2' => __('validation.custom.of_the.male'), + 'model' => __('models.classes.prize'), + ]), + ]) +
+ {{-- PICTURE --}} +
+ @include('back::partials.inputs.varchar-picture', [ + 'id' => 'prizePicture', + 'name' => 'picture', + 'width' => config('theme.models.prizes.picture_max_width'), + 'height' => config('theme.models.prizes.picture_max_height'), + 'model' => $prizeModel ?? null, + 'helper' => __('crud.minicrud.dimensions_must_be', [ + 'widthpx' => config('theme.models.prizes.picture_max_width') . 'px', + 'heightpx' => config('theme.models.prizes.picture_max_height') . 'px', + ]), + 'required' => false, + 'preview' => true, ])
@@ -114,7 +157,7 @@ ]), ])
- {{-- VALUE --}} + {{-- ARG CONTENT --}}
@include('back::partials.inputs.text-html', [ 'id' => 'contentValue', diff --git a/resources/views/pages/prizes/index.blade.php b/resources/views/pages/prizes/index.blade.php index 70b4784..2e0dd8f 100644 --- a/resources/views/pages/prizes/index.blade.php +++ b/resources/views/pages/prizes/index.blade.php @@ -19,7 +19,7 @@ @include('back::modules.table-col-sorter', [ 'cols' => [ - 'label_one' => Str::ucfirst(__('validation.custom.label_one')), + 'label' => Str::ucfirst(__('validation.custom.label')), 'quantity' => Str::ucfirst(__('validation.custom.quantity')), ], ]) @@ -27,7 +27,7 @@ @foreach ($prizeModels as $prizeModel) - {{ $prizeModel->label_one }} + {{ $prizeModel->label }} {{ $prizeModel->quantity }}
{{ \Carbon\Carbon::parse($participationModel->created_at)->format('d/m/Y à H:i') }} - {{ $participationModel->instantWin()->first()->prize->label_one }} + {{ $participationModel->instantWin()->first()->prize->label }} {{ $participationModel->customer->email }} @if ($settings->use_ean_codes) {{ $participationModel->codeEan }}