From a3a84446f8960a4acd97ad6bf1076ecd28e937fe Mon Sep 17 00:00:00 2001 From: Alexis Gousseau Date: Thu, 24 Jul 2025 11:32:12 +0200 Subject: [PATCH 01/11] feat: :card_file_box: add claims tables, seeder and relations --- app/Console/Commands/UserCreate.php | 12 +- app/Enums/Claims/ClaimMessageType.php | 21 ++ app/Enums/Claims/ClaimStatus.php | 25 ++ app/Enums/Claims/ClaimType.php | 23 ++ app/Enums/Users/RoleEnum.php | 2 + .../Requests/Bo/Users/StoreUserRequest.php | 22 +- app/Models/ActivityLog.php | 2 +- app/Models/Answer.php | 4 +- app/Models/Brand.php | 70 ++++- app/Models/BrandStat.php | 6 +- app/Models/Claim.php | 106 +++++++ app/Models/ClaimMailTemplate.php | 42 +++ app/Models/ClaimMessage.php | 62 ++++ app/Models/ClaimSubject.php | 50 ++++ app/Models/Customer.php | 20 +- app/Models/CustomerInfo.php | 8 +- app/Models/CustomerLogin.php | 26 +- app/Models/CustomerOptInHistory.php | 6 +- app/Models/Question.php | 8 +- app/Models/Service.php | 10 +- app/Models/ServiceStat.php | 10 +- app/Models/SingleOptin.php | 4 +- app/Models/User.php | 12 +- app/Traits/Models/MiniCrudModel.php | 10 +- composer.json | 3 +- composer.lock | 270 ++++++++++++++++++ database/factories/AnswerFactory.php | 2 +- database/factories/BrandFactory.php | 7 +- database/factories/ClaimFactory.php | 44 +++ .../factories/ClaimMailTemplateFactory.php | 31 ++ database/factories/ClaimMessageFactory.php | 34 +++ database/factories/ClaimSubjectFactory.php | 30 ++ database/factories/CustomerFactory.php | 2 +- database/factories/CustomerInfoFactory.php | 22 +- database/factories/CustomerLoginFactory.php | 6 +- database/factories/QuestionFactory.php | 2 +- database/factories/ServiceFactory.php | 2 +- database/factories/UserFactory.php | 8 +- .../assets/brands/default-logo-550x550.jpg | Bin 0 -> 7105 bytes ...7_24_091926_add_fields_to_brands_table.php | 44 +++ ..._092956_create_brand_users_pivot_table.php | 33 +++ ...2413_create_claim_mail_templates_table.php | 36 +++ ..._24_110652_create_claim_subjects_table.php | 35 +++ .../2025_07_24_113251_create_claims_table.php | 53 ++++ ...2025_07_24_122149_claim_messages_table.php | 38 +++ database/seeders/BrandSeeder.php | 12 +- database/seeders/BrandStatSeeder.php | 12 +- database/seeders/ClaimMailTemplateSeeder.php | 19 ++ database/seeders/ClaimMessageSeeder.php | 19 ++ database/seeders/ClaimSeeder.php | 19 ++ database/seeders/ClaimSubjectSeeder.php | 19 ++ database/seeders/DatabaseSeeder.php | 6 +- database/seeders/UserSeeder.php | 8 +- 53 files changed, 1262 insertions(+), 115 deletions(-) create mode 100644 app/Enums/Claims/ClaimMessageType.php create mode 100644 app/Enums/Claims/ClaimStatus.php create mode 100644 app/Enums/Claims/ClaimType.php create mode 100644 app/Models/Claim.php create mode 100644 app/Models/ClaimMailTemplate.php create mode 100644 app/Models/ClaimMessage.php create mode 100644 app/Models/ClaimSubject.php create mode 100644 database/factories/ClaimFactory.php create mode 100644 database/factories/ClaimMailTemplateFactory.php create mode 100644 database/factories/ClaimMessageFactory.php create mode 100644 database/factories/ClaimSubjectFactory.php create mode 100644 database/factories/assets/brands/default-logo-550x550.jpg create mode 100644 database/migrations/2025_07_24_091926_add_fields_to_brands_table.php create mode 100644 database/migrations/2025_07_24_092956_create_brand_users_pivot_table.php create mode 100644 database/migrations/2025_07_24_102413_create_claim_mail_templates_table.php create mode 100644 database/migrations/2025_07_24_110652_create_claim_subjects_table.php create mode 100644 database/migrations/2025_07_24_113251_create_claims_table.php create mode 100644 database/migrations/2025_07_24_122149_claim_messages_table.php create mode 100644 database/seeders/ClaimMailTemplateSeeder.php create mode 100644 database/seeders/ClaimMessageSeeder.php create mode 100644 database/seeders/ClaimSeeder.php create mode 100644 database/seeders/ClaimSubjectSeeder.php diff --git a/app/Console/Commands/UserCreate.php b/app/Console/Commands/UserCreate.php index 533eb23..d9cee85 100644 --- a/app/Console/Commands/UserCreate.php +++ b/app/Console/Commands/UserCreate.php @@ -173,11 +173,12 @@ class UserCreate extends Command $tmp = $this->choice( 'Select his role', [ - Str::ucFirst(RoleEnum::conceptor->label()), - Str::ucFirst(RoleEnum::admin->label()), - Str::ucFirst(RoleEnum::visitor->label()) + RoleEnum::conceptor->name, + RoleEnum::admin->name, + RoleEnum::visitor->name, + RoleEnum::marketing->name, ], - Str::ucFirst(RoleEnum::visitor->label()), + RoleEnum::visitor->name, ); if ($tmp === Str::ucFirst(RoleEnum::conceptor->label())) { $tmp = RoleEnum::conceptor; @@ -188,6 +189,9 @@ class UserCreate extends Command if ($tmp === Str::ucFirst(RoleEnum::visitor->label())) { $tmp = RoleEnum::visitor; } + if ($tmp === RoleEnum::marketing->name) { + $tmp = RoleEnum::marketing; + } $validator = Validator::make(['role' => $tmp], [ 'role' => 'required' ]); diff --git a/app/Enums/Claims/ClaimMessageType.php b/app/Enums/Claims/ClaimMessageType.php new file mode 100644 index 0000000..5c2aef9 --- /dev/null +++ b/app/Enums/Claims/ClaimMessageType.php @@ -0,0 +1,21 @@ +name => 'Automatique', + self::human->name => 'Humain', + ]; +} diff --git a/app/Enums/Claims/ClaimStatus.php b/app/Enums/Claims/ClaimStatus.php new file mode 100644 index 0000000..068a16d --- /dev/null +++ b/app/Enums/Claims/ClaimStatus.php @@ -0,0 +1,25 @@ +name => 'Non traitée', + self::treated->name => 'Traitée', + self::sentDigital->name => 'Transférée au service Digital', + self::sentMarketing->name => 'Retournée au Marketing', + ]; +} diff --git a/app/Enums/Claims/ClaimType.php b/app/Enums/Claims/ClaimType.php new file mode 100644 index 0000000..c44bd65 --- /dev/null +++ b/app/Enums/Claims/ClaimType.php @@ -0,0 +1,23 @@ +name => 'Classique', + self::br->name => 'BR', + self::rgpd->name => 'RGPD', + ]; +} diff --git a/app/Enums/Users/RoleEnum.php b/app/Enums/Users/RoleEnum.php index 53b5ada..4a30c1e 100644 --- a/app/Enums/Users/RoleEnum.php +++ b/app/Enums/Users/RoleEnum.php @@ -11,6 +11,7 @@ enum RoleEnum: int case conceptor = 1; case admin = 2; case visitor = 3; + case marketing = 4; /** * Optionnal labels definition. @@ -19,5 +20,6 @@ enum RoleEnum: int self::conceptor->name => 'Concepteur', self::admin->name => 'Administrateur', self::visitor->name => 'Visiteur', + self::marketing->name => 'Marketing', ]; } diff --git a/app/Http/Requests/Bo/Users/StoreUserRequest.php b/app/Http/Requests/Bo/Users/StoreUserRequest.php index ffa3d18..26dccdc 100644 --- a/app/Http/Requests/Bo/Users/StoreUserRequest.php +++ b/app/Http/Requests/Bo/Users/StoreUserRequest.php @@ -24,7 +24,7 @@ class StoreUserRequest extends FormRequest * * @return void */ - protected function prepareForValidation() + protected function prepareForValidation(): void { $this->merge([ 'published' => $this->published ? true : false @@ -40,9 +40,9 @@ class StoreUserRequest extends FormRequest { return [ 'first_name' => 'required|string|min:3|max:255', - 'last_name' => 'required|string|min:3|max:255', - 'email' => 'required|email:rfc,strict,dns,spoof,filter|unique:users,email', - 'password' => [ + 'last_name' => 'required|string|min:3|max:255', + 'email' => 'required|email:rfc,strict,dns,spoof,filter|unique:users,email', + 'password' => [ 'required', 'required_with:password_confirmation', 'confirmed', 'max:255', Password::min(8) ->letters() ->mixedCase() @@ -50,8 +50,8 @@ class StoreUserRequest extends FormRequest ->symbols() ->uncompromised() ], - 'role' => ['required', new Enum(RoleEnum::class)], - 'published' => 'required|boolean', + 'role' => ['required', new Enum(RoleEnum::class)], + 'published' => 'required|boolean', ]; } @@ -64,11 +64,11 @@ class StoreUserRequest extends FormRequest { return [ 'first_name' => trans('validation.attributes.first_name'), - 'last_name' => trans('validation.attributes.last_name'), - 'email' => trans('validation.attributes.email'), - 'password' => trans('validation.attributes.password'), - 'role' => trans('validation.attributes.role'), - 'published' => trans('validation.custom.publication') + 'last_name' => trans('validation.attributes.last_name'), + 'email' => trans('validation.attributes.email'), + 'password' => trans('validation.attributes.password'), + 'role' => trans('validation.attributes.role'), + 'published' => trans('validation.custom.publication') ]; } } diff --git a/app/Models/ActivityLog.php b/app/Models/ActivityLog.php index f696475..235f4bf 100644 --- a/app/Models/ActivityLog.php +++ b/app/Models/ActivityLog.php @@ -51,7 +51,7 @@ class ActivityLog extends Model /** * The attributes that should be cast. * - * @var array + * @var array */ protected $casts = [ 'is_anonymous' => 'bool', diff --git a/app/Models/Answer.php b/app/Models/Answer.php index 2191813..f7e7615 100644 --- a/app/Models/Answer.php +++ b/app/Models/Answer.php @@ -22,7 +22,7 @@ class Answer extends Model /** * The attributes that are mass assignable. * - * @var string[] + * @var array */ protected $fillable = [ 'answer', @@ -31,7 +31,7 @@ class Answer extends Model // * RELATIONS /** - * Question BelongsTo relation. + * Question belongs to relation. * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ diff --git a/app/Models/Brand.php b/app/Models/Brand.php index 0f24486..027326e 100644 --- a/app/Models/Brand.php +++ b/app/Models/Brand.php @@ -8,10 +8,14 @@ use Illuminate\Database\Eloquent\Model; use Rennokki\QueryCache\Traits\QueryCacheable; /** - * @property integer $id Id. - * @property string $name Name. - * @property-read \Illuminate\Support\Carbon $created_at Created date. - * @property-read \Illuminate\Support\Carbon $updated_at Updated date. + * @property integer $id Brand id. + * @property string $name Brand name. + * @property string $logo Brand logo. + * @property string $url Brand url link. + * @property string $url_claim Brand associative url claim. + * @property string $domain Brand domain. + * @property-read \Illuminate\Support\Carbon $created_at Brand created date. + * @property-read \Illuminate\Support\Carbon $updated_at Brand updated date. * * @property-read \Illuminate\Database\Eloquent\Collection * $services Service HasMany relation. @@ -40,10 +44,14 @@ class Brand extends Model /** * The attributes that are mass assignable. * - * @var string[] + * @var array */ protected $fillable = [ 'name', + 'logo', + 'url', + 'url_claim', + 'domain', ]; /** @@ -64,7 +72,7 @@ class Brand extends Model * * ! This is used to flush caching * - * @return array + * @return array */ protected function getCacheBaseTags(): array { @@ -97,7 +105,7 @@ class Brand extends Model // * RELATIONS /** - * Service hasMany relation. + * Service has many relation. * * @return \Illuminate\Database\Eloquent\Relations\HasMany */ @@ -107,7 +115,7 @@ class Brand extends Model } /** - * Question hasMany relation. + * Question has many relation. * * @return \Illuminate\Database\Eloquent\Relations\HasMany */ @@ -117,7 +125,7 @@ class Brand extends Model } /** - * CustomerInfo hasMany relation. + * CustomerInfo has many relation. * * @return \Illuminate\Database\Eloquent\Relations\HasMany */ @@ -127,7 +135,7 @@ class Brand extends Model } /** - * ServiceStat hasMany relation. + * ServiceStat has many relation. * * @return \Illuminate\Database\Eloquent\Relations\HasMany */ @@ -137,7 +145,7 @@ class Brand extends Model } /** - * SingleOptin hasMany relation. + * SingleOptin has many relation. * * @return \Illuminate\Database\Eloquent\Relations\HasMany */ @@ -146,6 +154,46 @@ class Brand extends Model return $this->hasMany(SingleOptin::class); } + /** + * Users many to many relation. + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + */ + public function users(): \Illuminate\Database\Eloquent\Relations\BelongsToMany + { + return $this->belongsToMany(User::class, 'brand_users'); + } + + /** + * Claim has many relation. + * + * @return \Illuminate\Database\Eloquent\Relations\HasMany + */ + public function claims(): \Illuminate\Database\Eloquent\Relations\HasMany + { + return $this->hasMany(Claim::class); + } + + /** + * ClaimSubject has many relation. + * + * @return \Illuminate\Database\Eloquent\Relations\HasMany + */ + public function claimSubjects(): \Illuminate\Database\Eloquent\Relations\HasMany + { + return $this->hasMany(ClaimSubject::class); + } + + /** + * ClaimMailTemplate has many relation. + * + * @return \Illuminate\Database\Eloquent\Relations\HasMany + */ + public function claimMailTemplates(): \Illuminate\Database\Eloquent\Relations\HasMany + { + return $this->hasMany(ClaimMailTemplate::class); + } + // * METHODS /** diff --git a/app/Models/BrandStat.php b/app/Models/BrandStat.php index db44d55..67bd961 100644 --- a/app/Models/BrandStat.php +++ b/app/Models/BrandStat.php @@ -28,7 +28,7 @@ class BrandStat extends Model /** * The attributes that are mass assignable. * - * @var string[] + * @var array */ protected $fillable = [ 'active', @@ -42,7 +42,7 @@ class BrandStat extends Model /** * The attributes that should be cast to native types. * - * @var array + * @var array */ public $casts = [ 'created_at' => 'date', @@ -65,7 +65,7 @@ class BrandStat extends Model // * RELATIONS /** - * Brand hasMany relation. + * Brand belongs to relation. * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ diff --git a/app/Models/Claim.php b/app/Models/Claim.php new file mode 100644 index 0000000..2620bc2 --- /dev/null +++ b/app/Models/Claim.php @@ -0,0 +1,106 @@ + + */ + protected $fillable = [ + 'reference', + 'first_name', + 'last_name', + 'email', + 'address', + 'city', + 'postcode', + 'file', + 'message', + 'type', + 'status', + 'brand_id', + 'subject_id', + 'customer_id', + ]; + + /** + * The attributes that should be cast. + * + * @var array + */ + protected $casts = [ + 'type' => ClaimType::class, + 'status' => ClaimStatus::class, + ]; + + // * RELATIONS + + /** + * Brand belongs to relation. + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ + public function brand(): \Illuminate\Database\Eloquent\Relations\BelongsTo + { + return $this->belongsTo(Brand::class); + } + + /** + * ClaimSubject subject belongs to relation. + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ + public function claimSubject(): \Illuminate\Database\Eloquent\Relations\BelongsTo + { + return $this->belongsTo(ClaimSubject::class); + } + + /** + * Customer subject belongs to relation. + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ + public function customer(): \Illuminate\Database\Eloquent\Relations\BelongsTo + { + return $this->belongsTo(Customer::class); + } + + /** + * ClaimMessage has many relation. + * + * @return \Illuminate\Database\Eloquent\Relations\HasMany + */ + public function claimMessages(): \Illuminate\Database\Eloquent\Relations\HasMany + { + return $this->hasMany(ClaimMessage::class); + } +} diff --git a/app/Models/ClaimMailTemplate.php b/app/Models/ClaimMailTemplate.php new file mode 100644 index 0000000..d9df387 --- /dev/null +++ b/app/Models/ClaimMailTemplate.php @@ -0,0 +1,42 @@ + + */ + protected $fillable = [ + 'label', + 'content', + 'brand_id', + ]; + + // * RELATIONS + + /** + * Brand belongs to relation. + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ + public function brand(): \Illuminate\Database\Eloquent\Relations\BelongsTo + { + return $this->belongsTo(Brand::class); + } +} diff --git a/app/Models/ClaimMessage.php b/app/Models/ClaimMessage.php new file mode 100644 index 0000000..e28435d --- /dev/null +++ b/app/Models/ClaimMessage.php @@ -0,0 +1,62 @@ + + */ + protected $fillable = [ + 'content', + 'type', + 'claim_id', + 'user_id', + ]; + + /** + * The attributes that should be cast. + * + * @var array + */ + protected $casts = [ + 'type' => ClaimMessageType::class, + ]; + + // * RELATIONS + + /** + * Claim belongs to relation. + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ + public function claim(): \Illuminate\Database\Eloquent\Relations\BelongsTo + { + return $this->belongsTo(Claim::class); + } + + /** + * User belongs to relation. + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ + public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo + { + return $this->belongsTo(User::class); + } +} diff --git a/app/Models/ClaimSubject.php b/app/Models/ClaimSubject.php new file mode 100644 index 0000000..7b8fe3f --- /dev/null +++ b/app/Models/ClaimSubject.php @@ -0,0 +1,50 @@ + + */ + protected $fillable = [ + 'label', + 'brand_id', + ]; + + // * RELATIONS + + /** + * Brand belongs to relation. + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ + public function brand(): \Illuminate\Database\Eloquent\Relations\BelongsTo + { + return $this->belongsTo(Brand::class); + } + + /** + * Claim has many relation. + * + * @return \Illuminate\Database\Eloquent\Relations\HasMany + */ + public function claims(): \Illuminate\Database\Eloquent\Relations\HasMany + { + return $this->hasMany(Claim::class); + } +} diff --git a/app/Models/Customer.php b/app/Models/Customer.php index b03dbd2..2cf6bbe 100644 --- a/app/Models/Customer.php +++ b/app/Models/Customer.php @@ -36,7 +36,7 @@ class Customer extends Model /** * The attributes that are mass assignable. * - * @var string[] + * @var array */ protected $fillable = [ 'email', @@ -45,7 +45,7 @@ class Customer extends Model // * RELATIONS /** - * CustomerInfo hasMany relation. + * CustomerInfo has many relation. * * @return \Illuminate\Database\Eloquent\Relations\HasMany */ @@ -55,7 +55,7 @@ class Customer extends Model } /** - * CustomerLogin hasMany relation. + * CustomerLogin has many relation. * * @return \Illuminate\Database\Eloquent\Relations\HasMany */ @@ -65,7 +65,7 @@ class Customer extends Model } /** - * CustomerOptInHistory hasMany relation. + * CustomerOptInHistory has many relation. * * @return \Illuminate\Database\Eloquent\Relations\HasMany */ @@ -75,7 +75,7 @@ class Customer extends Model } /** - * Customer Brand belongsToMany relation. + * Customer Brand belongs to many relation. * * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ @@ -94,6 +94,16 @@ class Customer extends Model return $this->morphToMany(Answer::class, 'model', 'model_answer', 'model_id', 'answer_id'); } + /** + * Claim has many relation. + * + * @return \Illuminate\Database\Eloquent\Relations\HasMany + */ + public function claims(): \Illuminate\Database\Eloquent\Relations\HasMany + { + return $this->hasMany(Claim::class); + } + // * METHODS /** diff --git a/app/Models/CustomerInfo.php b/app/Models/CustomerInfo.php index f45eba8..8a85190 100644 --- a/app/Models/CustomerInfo.php +++ b/app/Models/CustomerInfo.php @@ -36,7 +36,7 @@ class CustomerInfo extends Model /** * The attributes that are mass assignable. * - * @var string[] + * @var array */ protected $fillable = [ 'firstname', @@ -54,7 +54,7 @@ class CustomerInfo extends Model /** * The attributes that should be cast to native types. * - * @var array + * @var array */ protected $casts = [ 'country' => Country::class, @@ -83,7 +83,7 @@ class CustomerInfo extends Model // * RELATIONS /** - * Customer BelongsTo relation. + * Customer belongs to relation. * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ @@ -93,7 +93,7 @@ class CustomerInfo extends Model } /** - * Brand BelongsTo relation. + * Brand belongs to relation. * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ diff --git a/app/Models/CustomerLogin.php b/app/Models/CustomerLogin.php index 185b44f..146d240 100644 --- a/app/Models/CustomerLogin.php +++ b/app/Models/CustomerLogin.php @@ -23,28 +23,28 @@ class CustomerLogin extends Model { use HasFactory; - /** - * The model's attributes. - * - * @var array - */ - protected $attributes = [ - 'status' => false, - ]; - /** * The attributes that are mass assignable. * - * @var string[] + * @var array */ protected $fillable = [ 'password', ]; + /** + * The model's attributes. + * + * @var array + */ + protected $attributes = [ + 'status' => false, + ]; + /** * The attributes that should be cast to native types. * - * @var array + * @var array */ protected $casts = [ 'status' => 'bool', @@ -73,7 +73,7 @@ class CustomerLogin extends Model // * RELATIONS /** - * Customer BelongsTo relation. + * Customer belongs to relation. * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ @@ -83,7 +83,7 @@ class CustomerLogin extends Model } /** - * Brand BelongsTo relation. + * Brand belongs to relation. * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ diff --git a/app/Models/CustomerOptInHistory.php b/app/Models/CustomerOptInHistory.php index e01798a..dc4a0a5 100644 --- a/app/Models/CustomerOptInHistory.php +++ b/app/Models/CustomerOptInHistory.php @@ -30,7 +30,7 @@ class CustomerOptInHistory extends Model /** * The attributes that should be cast to native types. * - * @var array + * @var array */ protected $casts = [ 'new_value' => 'bool', @@ -39,7 +39,7 @@ class CustomerOptInHistory extends Model // * RELATIONS /** - * Customer BelongsTo relation. + * Customer belongs to relation. * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ @@ -49,7 +49,7 @@ class CustomerOptInHistory extends Model } /** - * Brand BelongsTo relation. + * Brand belongs to relation. * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ diff --git a/app/Models/Question.php b/app/Models/Question.php index c52efad..e92c814 100644 --- a/app/Models/Question.php +++ b/app/Models/Question.php @@ -26,7 +26,7 @@ class Question extends Model /** * The attributes that are mass assignable. * - * @var string[] + * @var array */ protected $fillable = [ 'question', @@ -37,7 +37,7 @@ class Question extends Model /** * Map attribute names to enum classes. * - * @var array + * @var array */ protected $casts = [ 'type' => QuestionType::class, @@ -46,7 +46,7 @@ class Question extends Model // * RELATIONS /** - * Brand BelongsTo relation. + * Brand belongs to relation. * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ @@ -56,7 +56,7 @@ class Question extends Model } /** - * Answer Has many relation. + * Answer has many relation. * * @return \Illuminate\Database\Eloquent\Relations\HasMany */ diff --git a/app/Models/Service.php b/app/Models/Service.php index b8b6cb0..782c5e8 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -44,7 +44,7 @@ class Service extends Model /** * The attributes that are mass assignable. * - * @var string[] + * @var array */ protected $fillable = [ 'name', @@ -54,7 +54,7 @@ class Service extends Model /** * The attributes that should be cast to native types. * - * @var array + * @var array */ protected $casts = [ 'bearer_token_date' => 'datetime', @@ -102,7 +102,7 @@ class Service extends Model // * RELATIONS /** - * Brand BelongsTo relation. + * Brand belongs to relation. * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ @@ -112,7 +112,7 @@ class Service extends Model } /** - * ServiceStat hasMany relation. + * ServiceStat has many relation. * * @return \Illuminate\Database\Eloquent\Relations\HasMany */ @@ -129,7 +129,7 @@ class Service extends Model * * ! This is used to flush caching * - * @return array + * @return array */ protected function getCacheBaseTags(): array { diff --git a/app/Models/ServiceStat.php b/app/Models/ServiceStat.php index e3941bd..734b982 100644 --- a/app/Models/ServiceStat.php +++ b/app/Models/ServiceStat.php @@ -24,7 +24,7 @@ class ServiceStat extends Model /** * The attributes that are mass assignable. * - * @var string[] + * @var array */ protected $fillable = [ 'date', @@ -33,7 +33,7 @@ class ServiceStat extends Model /** * The model's attributes. * - * @var array + * @var array */ protected $attributes = [ 'nb_calls' => 0, @@ -42,7 +42,7 @@ class ServiceStat extends Model /** * Map attribute names to enum classes. * - * @var array + * @var array */ protected $casts = [ 'date' => 'date', @@ -51,7 +51,7 @@ class ServiceStat extends Model // * RELATIONS /** - * Brand BelongsTo relation. + * Brand belongs to relation. * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ @@ -61,7 +61,7 @@ class ServiceStat extends Model } /** - * Service BelongsTo relation. + * Service belongs to relation. * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ diff --git a/app/Models/SingleOptin.php b/app/Models/SingleOptin.php index dbd1e38..b9c95d0 100644 --- a/app/Models/SingleOptin.php +++ b/app/Models/SingleOptin.php @@ -44,7 +44,7 @@ class SingleOptin extends Model /** * The attributes that are mass assignable. * - * @var string[] + * @var array */ protected $fillable = [ 'email', @@ -65,7 +65,7 @@ class SingleOptin extends Model // * RELATIONS /** - * Brand BelongsTo relation. + * Brand belongs to relation. * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ diff --git a/app/Models/User.php b/app/Models/User.php index b0981f5..1e40a87 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -55,7 +55,7 @@ class User extends Authenticatable /** * The attributes that should be cast. * - * @var array + * @var array */ protected $casts = [ 'role' => RoleEnum::class, @@ -112,4 +112,14 @@ class User extends Authenticatable AuthorizationException::class ); } + + /** + * Brands many to many relation. + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + */ + public function brands(): \Illuminate\Database\Eloquent\Relations\BelongsToMany + { + return $this->belongsToMany(Brand::class, 'brand_users'); + } } diff --git a/app/Traits/Models/MiniCrudModel.php b/app/Traits/Models/MiniCrudModel.php index 09109f1..c5058ed 100644 --- a/app/Traits/Models/MiniCrudModel.php +++ b/app/Traits/Models/MiniCrudModel.php @@ -3,8 +3,8 @@ namespace App\Traits\Models; use App\Enums\InputType; -use App\Lib\Helpers\FileStorageHelper; use App\Lib\Helpers\ToolboxHelper; +use Uwil\LaravelCommon\Helpers\FileHelper; trait MiniCrudModel { @@ -38,7 +38,7 @@ trait MiniCrudModel switch ($input['inputType']) { case InputType::text->value: $input['text'] = clean($input['text']); - $input['text'] = FileStorageHelper::storeModelFilesFromHtml($this, $input['text']); + $input['text'] = FileHelper::storeModelFilesFromHtml($this, $input['text']); break; } //end switch } //end foreach @@ -67,7 +67,7 @@ trait MiniCrudModel switch ($input['inputType']) { case InputType::text->value: $original = ToolboxHelper::getOriginal($this, 'data'); - FileStorageHelper::removeOldModelFilesFromHtml( + FileHelper::removeOldModelFilesFromHtml( $input['text'], $original[$index]['text'] ?? '' ); @@ -87,7 +87,7 @@ trait MiniCrudModel foreach ($this->data as $input) { switch ($input['inputType']) { case InputType::text->value: - FileStorageHelper::removeModelFilesOfHtml($input['text']); + FileHelper::removeModelFilesOfHtml($input['text']); break; } //end switch } //end foreach @@ -151,7 +151,7 @@ trait MiniCrudModel $data[$o]['value'] = \preg_replace( '/^\/|^/', '', - FileStorageHelper::storeFile($this, $input['value'], true) + FileHelper::storeFile($this, $input['value'], true) ); break; case InputType::selectEnum->value: diff --git a/composer.json b/composer.json index 566b56a..ab9afc3 100644 --- a/composer.json +++ b/composer.json @@ -41,7 +41,8 @@ "rennokki/laravel-eloquent-query-cache": "^3.5", "sentry/sentry-laravel": "^4.10", "uwil/admin-secure-laravel": "^3.0", - "uwil/k8s-laravel": "^1.4" + "uwil/k8s-laravel": "^1.4", + "uwil/laravel-common": "^3.4" }, "require-dev": { "brianium/paratest": "^7.2", diff --git a/composer.lock b/composer.lock index b412990..ae05dc9 100644 --- a/composer.lock +++ b/composer.lock @@ -1964,6 +1964,150 @@ ], "time": "2023-12-03T19:50:20+00:00" }, + { + "name": "intervention/gif", + "version": "4.2.2", + "source": { + "type": "git", + "url": "https://github.com/Intervention/gif.git", + "reference": "5999eac6a39aa760fb803bc809e8909ee67b451a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Intervention/gif/zipball/5999eac6a39aa760fb803bc809e8909ee67b451a", + "reference": "5999eac6a39aa760fb803bc809e8909ee67b451a", + "shasum": "" + }, + "require": { + "php": "^8.1" + }, + "require-dev": { + "phpstan/phpstan": "^2.1", + "phpunit/phpunit": "^10.0 || ^11.0 || ^12.0", + "slevomat/coding-standard": "~8.0", + "squizlabs/php_codesniffer": "^3.8" + }, + "type": "library", + "autoload": { + "psr-4": { + "Intervention\\Gif\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Oliver Vogel", + "email": "oliver@intervention.io", + "homepage": "https://intervention.io/" + } + ], + "description": "Native PHP GIF Encoder/Decoder", + "homepage": "https://github.com/intervention/gif", + "keywords": [ + "animation", + "gd", + "gif", + "image" + ], + "support": { + "issues": "https://github.com/Intervention/gif/issues", + "source": "https://github.com/Intervention/gif/tree/4.2.2" + }, + "funding": [ + { + "url": "https://paypal.me/interventionio", + "type": "custom" + }, + { + "url": "https://github.com/Intervention", + "type": "github" + }, + { + "url": "https://ko-fi.com/interventionphp", + "type": "ko_fi" + } + ], + "time": "2025-03-29T07:46:21+00:00" + }, + { + "name": "intervention/image", + "version": "3.11.3", + "source": { + "type": "git", + "url": "https://github.com/Intervention/image.git", + "reference": "d0f097b8a3fa8fb758efc9440b513aa3833cda17" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Intervention/image/zipball/d0f097b8a3fa8fb758efc9440b513aa3833cda17", + "reference": "d0f097b8a3fa8fb758efc9440b513aa3833cda17", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "intervention/gif": "^4.2", + "php": "^8.1" + }, + "require-dev": { + "mockery/mockery": "^1.6", + "phpstan/phpstan": "^2.1", + "phpunit/phpunit": "^10.0 || ^11.0 || ^12.0", + "slevomat/coding-standard": "~8.0", + "squizlabs/php_codesniffer": "^3.8" + }, + "suggest": { + "ext-exif": "Recommended to be able to read EXIF data properly." + }, + "type": "library", + "autoload": { + "psr-4": { + "Intervention\\Image\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Oliver Vogel", + "email": "oliver@intervention.io", + "homepage": "https://intervention.io/" + } + ], + "description": "PHP image manipulation", + "homepage": "https://image.intervention.io/", + "keywords": [ + "gd", + "image", + "imagick", + "resize", + "thumbnail", + "watermark" + ], + "support": { + "issues": "https://github.com/Intervention/image/issues", + "source": "https://github.com/Intervention/image/tree/3.11.3" + }, + "funding": [ + { + "url": "https://paypal.me/interventionio", + "type": "custom" + }, + { + "url": "https://github.com/Intervention", + "type": "github" + }, + { + "url": "https://ko-fi.com/interventionphp", + "type": "ko_fi" + } + ], + "time": "2025-05-22T17:26:23+00:00" + }, { "name": "jean85/pretty-package-versions", "version": "2.1.0", @@ -2023,6 +2167,68 @@ }, "time": "2024-11-18T16:19:46+00:00" }, + { + "name": "kwaadpepper/image-resizer", + "version": "3.1.0", + "source": { + "type": "git", + "url": "https://github.com/Kwaadpepper/image-resizer.git", + "reference": "e0747fddc4e31ce57bda9db735060e279ae01780" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Kwaadpepper/image-resizer/zipball/e0747fddc4e31ce57bda9db735060e279ae01780", + "reference": "e0747fddc4e31ce57bda9db735060e279ae01780", + "shasum": "" + }, + "require": { + "illuminate/support": "~11|~12", + "intervention/image": "^3.6", + "laravel/framework": "~11|~12", + "php": "^8.2" + }, + "require-dev": { + "larastan/larastan": "^2.0", + "orchestra/testbench": "^9.0", + "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/3.1.0" + }, + "time": "2025-03-02T07:22:50+00:00" + }, { "name": "laravel/framework", "version": "v11.37.0", @@ -7717,6 +7923,70 @@ ], "description": "Laravel requirements for k8s" }, + { + "name": "uwil/laravel-common", + "version": "3.4.2", + "source": { + "type": "git", + "url": "git@lab.s-web.fr:ldc-web/projets/laravel-common.git", + "reference": "5959b1ae8aaaf118e5d1e1f34be8188ca41bcc42" + }, + "dist": { + "type": "zip", + "url": "https://lab.s-web.fr/api/v4/projects/215/packages/composer/archives/uwil/laravel-common.zip?sha=5959b1ae8aaaf118e5d1e1f34be8188ca41bcc42", + "reference": "5959b1ae8aaaf118e5d1e1f34be8188ca41bcc42", + "shasum": "" + }, + "require": { + "illuminate/support": "~11|~12", + "kwaadpepper/image-resizer": "^3.0", + "laravel/framework": "~11|~12", + "mews/purifier": "^3.4", + "php": "~8.3", + "sentry/sentry-laravel": "^4.10" + }, + "require-dev": { + "larastan/larastan": "^2.9", + "orchestra/testbench": "^9.0", + "phpunit/php-code-coverage": "^11.0", + "phpunit/phpunit": "^11.0", + "slevomat/coding-standard": "^8.3", + "squizlabs/php_codesniffer": "^3.7" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Uwil\\LaravelCommon\\CommonServiceProvider" + ] + } + }, + "autoload": { + "files": [ + "src/Helpers/methods.php" + ], + "psr-4": { + "Uwil\\LaravelCommon\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Uwil\\LaravelCommon\\Tests\\": "tests" + } + }, + "scripts": { + "test": [ + "vendor/bin/phpunit" + ], + "post-autoload-dump": [ + "@php ./vendor/bin/testbench package:discover --ansi" + ] + }, + "license": [ + "MIT" + ], + "description": "UWIL Laravel common utils" + }, { "name": "vlucas/phpdotenv", "version": "v5.6.1", diff --git a/database/factories/AnswerFactory.php b/database/factories/AnswerFactory.php index 2d810c0..dab69be 100644 --- a/database/factories/AnswerFactory.php +++ b/database/factories/AnswerFactory.php @@ -19,7 +19,7 @@ class AnswerFactory extends Factory * * @return array */ - public function definition() + public function definition(): array { return [ 'answer' => $this->faker->realText(20), diff --git a/database/factories/BrandFactory.php b/database/factories/BrandFactory.php index 777ac2b..b005079 100644 --- a/database/factories/BrandFactory.php +++ b/database/factories/BrandFactory.php @@ -19,10 +19,13 @@ class BrandFactory extends Factory * * @return array */ - public function definition() + public function definition(): array { return [ - 'name' => $this->faker->company, + 'name' => $this->faker->company, + 'url' => $this->faker->url, + 'url_claim' => $this->faker->url, + 'domain' => $this->faker->domainName, ]; } } diff --git a/database/factories/ClaimFactory.php b/database/factories/ClaimFactory.php new file mode 100644 index 0000000..e46c9e8 --- /dev/null +++ b/database/factories/ClaimFactory.php @@ -0,0 +1,44 @@ + $this->faker->firstName(), + 'last_name' => $this->faker->lastName(), + 'email' => $this->faker->email(), + 'address' => $this->faker->optional()->address(), + 'city' => $this->faker->optional()->city(), + 'postcode' => $this->faker->optional()->postcode(), + 'message' => $this->faker->sentence(10), + 'type' => collect(ClaimType::toArray())->random()->value, + 'status' => collect(ClaimStatus::toArray())->random()->value, + 'brand_id' => $this->faker->randomElement(Brand::pluck('id')), + 'subject_id' => $this->faker->randomElement(ClaimSubject::pluck('id')), + 'customer_id' => $this->faker->boolean(50) ? $this->faker->randomElement(Customer::pluck('id')) : null, + ]; + } +} diff --git a/database/factories/ClaimMailTemplateFactory.php b/database/factories/ClaimMailTemplateFactory.php new file mode 100644 index 0000000..131a395 --- /dev/null +++ b/database/factories/ClaimMailTemplateFactory.php @@ -0,0 +1,31 @@ + $this->faker->word(), + 'content' => $this->faker->sentence(10), + 'brand_id' => $this->faker->randomElement(Brand::pluck('id')), + ]; + } +} diff --git a/database/factories/ClaimMessageFactory.php b/database/factories/ClaimMessageFactory.php new file mode 100644 index 0000000..f6fd58c --- /dev/null +++ b/database/factories/ClaimMessageFactory.php @@ -0,0 +1,34 @@ + $this->faker->sentence(10), + 'type' => collect(ClaimMessageType::toArray())->random()->value, + 'claim_id' => $this->faker->randomElement(Claim::pluck('id')), + 'user_id' => $this->faker->boolean(50) ? $this->faker->randomElement(User::pluck('id')) : null, + ]; + } +} diff --git a/database/factories/ClaimSubjectFactory.php b/database/factories/ClaimSubjectFactory.php new file mode 100644 index 0000000..5282a82 --- /dev/null +++ b/database/factories/ClaimSubjectFactory.php @@ -0,0 +1,30 @@ + $this->faker->word(), + 'brand_id' => $this->faker->randomElement(Brand::pluck('id')), + ]; + } +} diff --git a/database/factories/CustomerFactory.php b/database/factories/CustomerFactory.php index be9fad3..80dadc2 100644 --- a/database/factories/CustomerFactory.php +++ b/database/factories/CustomerFactory.php @@ -19,7 +19,7 @@ class CustomerFactory extends Factory * * @return array */ - public function definition() + public function definition(): array { return [ 'email' => preg_replace( diff --git a/database/factories/CustomerInfoFactory.php b/database/factories/CustomerInfoFactory.php index 6aadcaa..919ac10 100644 --- a/database/factories/CustomerInfoFactory.php +++ b/database/factories/CustomerInfoFactory.php @@ -22,7 +22,7 @@ class CustomerInfoFactory extends Factory * * @return array */ - public function definition() + public function definition(): array { $faker = \Faker\Factory::create('fr_FR'); $faker->addProvider(new \Faker\Provider\fr_FR\Address($faker)); @@ -36,17 +36,17 @@ class CustomerInfoFactory extends Factory $phone = '0388982532'; } return [ - 'firstname' => $faker->firstName, - 'lastname' => $faker->lastName, + 'firstname' => $faker->firstName, + 'lastname' => $faker->lastName, 'birth_date' => $faker->dateTimeBetween('-60 years', '-18 years'), - 'address' => $faker->address, - 'address2' => '', - 'phone' => $phone, - 'country' => $country->value, - 'city' => $faker->city, - 'postcode' => $faker->postcode, - 'opt_in' => $faker->boolean, - 'hashcode' => $faker->sha1 + 'address' => $faker->address, + 'address2' => '', + 'phone' => $phone, + 'country' => $country->value, + 'city' => $faker->city, + 'postcode' => $faker->postcode, + 'opt_in' => $faker->boolean, + 'hashcode' => $faker->sha1 ]; } } diff --git a/database/factories/CustomerLoginFactory.php b/database/factories/CustomerLoginFactory.php index b1b3dd9..7d4c3c9 100644 --- a/database/factories/CustomerLoginFactory.php +++ b/database/factories/CustomerLoginFactory.php @@ -27,7 +27,7 @@ class CustomerLoginFactory extends Factory * * @return array */ - public function definition() + public function definition(): array { $bool = $this->faker->boolean; // * Force first to be active. @@ -36,9 +36,9 @@ class CustomerLoginFactory extends Factory $bool = false; } return [ - 'password' => 'testPassword', + 'password' => 'testPassword', 'last_connection' => Carbon::now(), - 'status' => $bool + 'status' => $bool ]; } } diff --git a/database/factories/QuestionFactory.php b/database/factories/QuestionFactory.php index d86a99d..ff13112 100644 --- a/database/factories/QuestionFactory.php +++ b/database/factories/QuestionFactory.php @@ -24,7 +24,7 @@ class QuestionFactory extends Factory { return [ 'question' => $this->faker->realText(40), - 'type' => collect(QuestionType::toArray())->random()->value, + 'type' => collect(QuestionType::toArray())->random()->value, ]; } } diff --git a/database/factories/ServiceFactory.php b/database/factories/ServiceFactory.php index 00a3a8f..7ccb571 100644 --- a/database/factories/ServiceFactory.php +++ b/database/factories/ServiceFactory.php @@ -19,7 +19,7 @@ class ServiceFactory extends Factory * * @return array */ - public function definition() + public function definition(): array { return [ 'name' => $this->faker->lexify('?????????') diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index 46cb311..d6ebccc 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -13,13 +13,13 @@ class UserFactory extends Factory * * @return array */ - public function definition() + public function definition(): array { $published = $this->faker->boolean(75); return [ - 'first_name' => fake()->firstname(), - 'last_name' => fake()->lastname(), - 'email' => fake()->unique()->safeEmail(), + 'first_name' => $this->faker->firstname(), + 'last_name' => $this->faker->lastname(), + 'email' => $this->faker->unique()->safeEmail(), 'email_verified_at' => now(), 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', 'remember_token' => Str::random(10), diff --git a/database/factories/assets/brands/default-logo-550x550.jpg b/database/factories/assets/brands/default-logo-550x550.jpg new file mode 100644 index 0000000000000000000000000000000000000000..00854b07b82f1ca51d2b24ce0c19e02c3db2422b GIT binary patch literal 7105 zcmeH`c{tSj9>>39Hp?JFL&I1`G*L`rE5q2vQnEA%bv4v6l;e)IM$VuGbHgFB+_F!W zsKijoQOK4(qe3c6G_;pg%v{d7xAQ#ruY2#)U-y~s@A>?GfBe4B=lQ00aU6Wc2~UF<=A45eOs#E{;SZB_zZpQ3}#1DJhh){CZghRTZq7stN|9j@zoE zuBoSm!RVT7)-y095{XzHGm+nARpp84JhbGIv(>PxK?LGqgRD*T(W98Rh3PO$Yx`;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_table.php b/database/migrations/2025_07_24_091926_add_fields_to_brands_table.php new file mode 100644 index 0000000..a53c76d --- /dev/null +++ b/database/migrations/2025_07_24_091926_add_fields_to_brands_table.php @@ -0,0 +1,44 @@ +id()->comment('Brand id.')->change(); + $table->string('name')->comment('Brand name.')->change(); + $table->string('logo')->comment('Brand logo.')->after('name'); + $table->string('url')->comment('Brand url link.')->after('logo'); + $table->string('url_claim')->comment('Brand associative url claim.')->after('url'); + $table->string('domain')->comment('Brand domain.')->after('url_claim'); + $table->timestamp('created_at')->nullable()->comment('Brand created date.')->change(); + $table->timestamp('updated_at')->nullable()->comment('Brand updated date.')->change(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down(): void + { + Schema::table('brands', function (Blueprint $table) { + $table->id()->change(); + $table->string('name')->change(); + $table->dropColumn('logo'); + $table->dropColumn('url'); + $table->dropColumn('url_claim'); + $table->dropColumn('domain'); + }); + } +}; diff --git a/database/migrations/2025_07_24_092956_create_brand_users_pivot_table.php b/database/migrations/2025_07_24_092956_create_brand_users_pivot_table.php new file mode 100644 index 0000000..d4cdd46 --- /dev/null +++ b/database/migrations/2025_07_24_092956_create_brand_users_pivot_table.php @@ -0,0 +1,33 @@ +foreignId('brand_id')->comment('Brand associated.')->constrained('brands') + ->onUpdate('cascade')->onDelete('cascade'); + $table->foreignId('user_id')->comment('User associated.')->constrained('users') + ->onUpdate('cascade')->onDelete('cascade'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down(): void + { + Schema::dropIfExists('brand_users'); + } +}; diff --git a/database/migrations/2025_07_24_102413_create_claim_mail_templates_table.php b/database/migrations/2025_07_24_102413_create_claim_mail_templates_table.php new file mode 100644 index 0000000..8ddd786 --- /dev/null +++ b/database/migrations/2025_07_24_102413_create_claim_mail_templates_table.php @@ -0,0 +1,36 @@ +id()->comment('Mail template id.'); + $table->string('label')->comment('Mail template label.'); + $table->text('content')->comment('Mail template content.'); + $table->foreignId('brand_id')->comment('Mail template associated Brand.')->constrained('brands') + ->onUpdate('cascade')->onDelete('cascade'); + $table->timestamp('created_at')->nullable()->comment('Mail template created date.'); + $table->timestamp('updated_at')->nullable()->comment('Mail template updated date.'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down(): void + { + Schema::dropIfExists('claim_mail_templates'); + } +}; diff --git a/database/migrations/2025_07_24_110652_create_claim_subjects_table.php b/database/migrations/2025_07_24_110652_create_claim_subjects_table.php new file mode 100644 index 0000000..466903e --- /dev/null +++ b/database/migrations/2025_07_24_110652_create_claim_subjects_table.php @@ -0,0 +1,35 @@ +id()->comment('Subject id.'); + $table->string('label')->comment('Subject label.'); + $table->foreignId('brand_id')->comment('Subject associated Brand.')->constrained('brands') + ->onUpdate('cascade')->onDelete('cascade'); + $table->timestamp('created_at')->nullable()->comment('Subject created date.'); + $table->timestamp('updated_at')->nullable()->comment('Subject updated date.'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down(): void + { + Schema::dropIfExists('claim_subjects'); + } +}; diff --git a/database/migrations/2025_07_24_113251_create_claims_table.php b/database/migrations/2025_07_24_113251_create_claims_table.php new file mode 100644 index 0000000..21193d8 --- /dev/null +++ b/database/migrations/2025_07_24_113251_create_claims_table.php @@ -0,0 +1,53 @@ +id()->comment('Claim id.'); + $table->string('reference')->nullable()->default(null)->comment('Claim reference.'); + $table->string('first_name')->comment('Claimant\'s first name.'); + $table->string('last_name')->comment('Claimant\'s last name.'); + $table->string('email')->comment('Claimant\'s email.'); + $table->string('address')->nullable()->comment('Claimant\'s address.'); + $table->string('city')->nullable()->comment('Claimant\'s city.'); + $table->string('postcode')->nullable()->comment('Claimant\'s postcode.'); + $table->string('file')->nullable()->comment('Claimant\'s file.'); + $table->text('message')->comment('Claimant\'s message.'); + $table->unsignedTinyInteger('type')->default(ClaimType::classic) + ->comment('Claim type (ClaimType enum).'); + $table->unsignedTinyInteger('status')->default(ClaimStatus::untreated) + ->comment('Claim status (ClaimStatus enum).'); + $table->foreignId('brand_id')->comment('Claim associated Brand.')->constrained('brands') + ->onUpdate('cascade')->onDelete('cascade'); + $table->foreignId('subject_id')->comment('Claim associated Subject.')->constrained('claim_subjects') + ->onUpdate('cascade')->onDelete('cascade'); + $table->foreignId('customer_id')->nullable()->comment('Claim associated Customer.') + ->constrained('customers')->onUpdate('cascade')->onDelete('set null'); + $table->timestamp('created_at')->nullable()->comment('Claim created date.'); + $table->timestamp('updated_at')->nullable()->comment('Claim updated date.'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down(): void + { + Schema::dropIfExists('claims'); + } +}; diff --git a/database/migrations/2025_07_24_122149_claim_messages_table.php b/database/migrations/2025_07_24_122149_claim_messages_table.php new file mode 100644 index 0000000..30ac48e --- /dev/null +++ b/database/migrations/2025_07_24_122149_claim_messages_table.php @@ -0,0 +1,38 @@ +id()->comment('Message id.'); + $table->text('content')->comment('Message content.'); + $table->unsignedTinyInteger('type')->comment('Message type (MessageType enum).'); + $table->foreignId('claim_id')->comment('Message associated Claim.')->constrained('claims') + ->onUpdate('cascade')->onDelete('cascade'); + $table->foreignId('user_id')->nullable()->comment('Message associated User.')->constrained('users') + ->onUpdate('cascade')->onDelete('cascade'); + $table->timestamp('created_at')->nullable()->comment('Message created date.'); + $table->timestamp('updated_at')->nullable()->comment('Message updated date.'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down(): void + { + Schema::dropIfExists('claim_messages'); + } +}; diff --git a/database/seeders/BrandSeeder.php b/database/seeders/BrandSeeder.php index 0012ec6..7b6958c 100644 --- a/database/seeders/BrandSeeder.php +++ b/database/seeders/BrandSeeder.php @@ -7,6 +7,7 @@ use App\Models\Brand; use App\Models\Question; use App\Models\Service; use Illuminate\Database\Seeder; +use Uwil\LaravelCommon\Helpers\FileHelper; class BrandSeeder extends Seeder { @@ -15,10 +16,17 @@ class BrandSeeder extends Seeder * * @return void */ - public function run() + public function run(): void { /** @var \App\Models\Brand $brand */ - Brand::factory(10)->create()->each(function ($brand) { + Brand::factory(10)->make()->each(function ($brand) { + $brand->logo = FileHelper::storeFile( + $brand, + new \SplFileInfo( + \resource_path('../database/factories/assets/brands/default-logo-550x550.jpg') + ) + ); + $brand->saveOrFail(); Service::factory(1)->make()->each( /** @var \App\Models\Service $service*/ function ($service) use ($brand) { diff --git a/database/seeders/BrandStatSeeder.php b/database/seeders/BrandStatSeeder.php index d1d6a52..46be3e5 100644 --- a/database/seeders/BrandStatSeeder.php +++ b/database/seeders/BrandStatSeeder.php @@ -14,7 +14,7 @@ class BrandStatSeeder extends Seeder * * @return void */ - public function run() + public function run(): void { BrandStat::truncate(); // * On génère 1 an pour chaque marque. @@ -36,13 +36,13 @@ class BrandStatSeeder extends Seeder $pOld = 1 - $pNew; $brandStat = new BrandStat([ - 'active' => \floor($total * $pActive), - 'inactive' => \ceil($total * $pInactive), - 'old_accounts' => \ceil($total * $pOld), - 'new_accounts' => \floor($total * $pNew), + 'active' => \floor($total * $pActive), + 'inactive' => \ceil($total * $pInactive), + 'old_accounts' => \ceil($total * $pOld), + 'new_accounts' => \floor($total * $pNew), 'total_accounts' => $total, // 15% optin - 'total_opt_in' => ceil($total * 0.15) + 'total_opt_in' => ceil($total * 0.15) ]); $brandStat->brand()->associate($brand); $brandStat->created_at = $startDay; diff --git a/database/seeders/ClaimMailTemplateSeeder.php b/database/seeders/ClaimMailTemplateSeeder.php new file mode 100644 index 0000000..ed283e6 --- /dev/null +++ b/database/seeders/ClaimMailTemplateSeeder.php @@ -0,0 +1,19 @@ +create(); + } +} diff --git a/database/seeders/ClaimMessageSeeder.php b/database/seeders/ClaimMessageSeeder.php new file mode 100644 index 0000000..a99158f --- /dev/null +++ b/database/seeders/ClaimMessageSeeder.php @@ -0,0 +1,19 @@ +create(); + } +} diff --git a/database/seeders/ClaimSeeder.php b/database/seeders/ClaimSeeder.php new file mode 100644 index 0000000..139d6c6 --- /dev/null +++ b/database/seeders/ClaimSeeder.php @@ -0,0 +1,19 @@ +create(); + } +} diff --git a/database/seeders/ClaimSubjectSeeder.php b/database/seeders/ClaimSubjectSeeder.php new file mode 100644 index 0000000..cf7b460 --- /dev/null +++ b/database/seeders/ClaimSubjectSeeder.php @@ -0,0 +1,19 @@ +create(); + } +} diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 68ec9ee..82a52e1 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -11,7 +11,7 @@ class DatabaseSeeder extends Seeder * * @return void */ - public function run() + public function run(): void { $this->call([ BrandSeeder::class, @@ -19,6 +19,10 @@ class DatabaseSeeder extends Seeder BrandStatSeeder::class, UserSeeder::class, SingleOptinSeeder::class, + ClaimMailTemplateSeeder::class, + ClaimSubjectSeeder::class, + ClaimSeeder::class, + ClaimMessageSeeder::class, ]); } } diff --git a/database/seeders/UserSeeder.php b/database/seeders/UserSeeder.php index ba66561..8019b31 100644 --- a/database/seeders/UserSeeder.php +++ b/database/seeders/UserSeeder.php @@ -2,6 +2,7 @@ namespace Database\Seeders; +use App\Models\Brand; use App\Models\User; use Illuminate\Database\Seeder; @@ -12,8 +13,11 @@ class UserSeeder extends Seeder * * @return void */ - public function run() + public function run(): void { - User::factory(20)->create(); + User::factory(20)->create()->each(function ($user) { + $brands = Brand::inRandomOrder()->take(rand(1, 3))->pluck('id'); + $user->brands()->attach($brands); + }); } } From 187b96fbaf165d7e1b8665a64f17d174e7a1bdd7 Mon Sep 17 00:00:00 2001 From: Alexis Gousseau Date: Thu, 24 Jul 2025 17:30:46 +0200 Subject: [PATCH 02/11] =?UTF-8?q?feat:=20=E2=9C=85=20add=20claims=20api=20?= =?UTF-8?q?route=20and=20tests=20for=20V4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Api/V4/ClaimController.php | 31 ++++ app/Http/Requests/Api/V4/SendClaimRequest.php | 63 ++++++++ app/Models/Claim.php | 37 +++++ routes/api.php | 14 +- tests/CRM/ApiV4/ClaimTest.php | 148 ++++++++++++++++++ tests/Client/CrmClientRouterTest.php | 6 +- 6 files changed, 293 insertions(+), 6 deletions(-) create mode 100644 app/Http/Controllers/Api/V4/ClaimController.php create mode 100644 app/Http/Requests/Api/V4/SendClaimRequest.php create mode 100644 tests/CRM/ApiV4/ClaimTest.php diff --git a/app/Http/Controllers/Api/V4/ClaimController.php b/app/Http/Controllers/Api/V4/ClaimController.php new file mode 100644 index 0000000..01945e2 --- /dev/null +++ b/app/Http/Controllers/Api/V4/ClaimController.php @@ -0,0 +1,31 @@ +fill($request->validated()); + if (!$claimModel->saveOrFail()) { + throw new CrmException('Api failed to store claim.'); + } + $claimModel->brand()->associate($service->brand); + + return response()->json(); + } +} diff --git a/app/Http/Requests/Api/V4/SendClaimRequest.php b/app/Http/Requests/Api/V4/SendClaimRequest.php new file mode 100644 index 0000000..08af906 --- /dev/null +++ b/app/Http/Requests/Api/V4/SendClaimRequest.php @@ -0,0 +1,63 @@ + [Trim::class, TrimDuplicateSpaces::class, Capitalize::class], + 'last_name' => [Trim::class, TrimDuplicateSpaces::class, Capitalize::class], + 'email' => [Trim::class, RemoveSpaces::class, Lowercase::class], + 'address' => [Trim::class, TrimDuplicateSpaces::class], + 'city' => [Trim::class, TrimDuplicateSpaces::class], + 'postcode' => [Trim::class], + 'file' => [Trim::class], + 'message' => [Trim::class], + ]; + + /** + * Determine if the user is authorized to make this request. + * + * @return boolean + */ + public function authorize(): bool + { + return true; + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules(): array + { + $countryList = ($this->currentCountry && $this->currentCountry->get('iso')) ? + $this->currentCountry->get('iso') : implode(',', Country::getValidIsoAplha2Codes()); + return [ + 'first_name' => 'required|string|between:3,255', + 'last_name' => 'required|string|between:3,255', + 'email' => 'required|email:rfc,dns,spoof,filter|max:255', + 'address' => 'sometimes|nullable|string|max:255', + 'city' => 'sometimes|nullable|string|between:2,255', + 'postcode' => ['sometimes', 'nullable', 'string', "postal_code:{$countryList}"], + 'file' => 'sometimes|nullable|mimes:jpg,jpeg,png,pdf|max:5120', + 'message' => 'required|string|min:3', + 'brand_id' => 'required|integer|exists:brands,id', + 'subject_id' => 'required|integer|exists:claim_subjects,id', + 'customer_id' => 'sometimes|nullable|integer|exists:customers,id', + ]; + } +} diff --git a/app/Models/Claim.php b/app/Models/Claim.php index 2620bc2..c7fc7bf 100644 --- a/app/Models/Claim.php +++ b/app/Models/Claim.php @@ -62,6 +62,19 @@ class Claim extends Model 'status' => ClaimStatus::class, ]; + /** + * Perform any actions required after the model boots. + * + * @return void + */ + protected static function booted(): void + { + static::created(function (self $model) { + $model->reference = self::encodeIntegerToBase36($model->getKey()); + $model->saveOrFail(); + }); + } + // * RELATIONS /** @@ -103,4 +116,28 @@ class Claim extends Model { return $this->hasMany(ClaimMessage::class); } + + // * METHODS + + /** + * Convert the integer to base 36 and make uppercase. + * + * @param integer $int + * @return string + */ + public static function encodeIntegerToBase36(int $int): string + { + return strtoupper(base_convert($int, 10, 36)); + } + + /** + * Convert back to base 10 from base 36, case insensitive. + * + * @param string $str + * @return string + */ + public static function decodeBase36ToInteger(string $str): string + { + return base_convert(strtolower($str), 36, 10); + } } diff --git a/routes/api.php b/routes/api.php index 7439fd3..f1780d3 100644 --- a/routes/api.php +++ b/routes/api.php @@ -1,20 +1,22 @@ name('apiV2.')->group(function () { Route::get('/question/{serviceQuestion}', [V2StatsController::class, 'questionStats']) ->name('questionStats'); }); + + // * CLAIMS + Route::post('/claim', [V2ClaimController::class, 'store'])->name('claim.store'); }); }); @@ -134,5 +139,8 @@ Route::prefix('v4')->name('apiV4.')->group(function () { Route::get('/question/{serviceQuestion}', [V4StatsController::class, 'questionStats']) ->name('questionStats'); }); + + // * CLAIMS + Route::post('/claim', [V4ClaimController::class, 'store'])->name('claim.store'); }); }); diff --git a/tests/CRM/ApiV4/ClaimTest.php b/tests/CRM/ApiV4/ClaimTest.php new file mode 100644 index 0000000..f17e97c --- /dev/null +++ b/tests/CRM/ApiV4/ClaimTest.php @@ -0,0 +1,148 @@ + */ + private array $skeleton; + + /** + * Prepare data. + * + * @return void + */ + protected function setUp(): void + { + parent::setUp(); + + $this->skeleton = [ + 'first_name' => 'Jean', + 'last_name' => 'Bond', + 'email' => 'claim@hotmail.fr', + 'message' => 'Ceci est un message.', + 'address' => '10 rue des totos', + 'city' => 'Le Mans', + 'postcode' => '72100', + 'file' => UploadedFile::fake()->image('photo.jpg'), + ]; + } + + /** + * Test save claim should work. + * route: apiV4.claim.store + * + * @return void + */ + public function testSendClaimShouldWork(): void + { + extract($this->getCustomer(true, false)); + $subject = ClaimSubject::query()->firstOrNew(); + $customer = Customer::query()->firstOrNew(); + + $response = $this->callApiWithToken($service, 'post', route('apiV4.claim.store'), \array_merge( + $this->skeleton, + [ + 'brand_id' => $brand->getKey(), + 'subject_id' => $subject->getKey(), + 'customer_id' => $customer->getKey(), + ] + )); + $claimModel = Claim::query()->where([ + ['email', 'claim@hotmail.fr'], + ['brand_id', $brand->getKey()], + ['subject_id', $subject->getKey()], + ['customer_id', $customer->getKey()], + ])->exists(); + $json = $response->decodeResponseJson(); + $this->assertApiResponseStatusIs($json, ApiStatus::OK); + $this->assertTrue($claimModel, 'Claim should have been stored.'); + } + + /** + * Test save claim with inexistent models should fail. + * route: apiV4.claim.store + * + * @return void + */ + public function testSendClaimWithInexistentModelsShouldFail(): void + { + extract($this->getCustomer(true, false)); + + $response = $this->callApiWithToken($service, 'post', route('apiV4.claim.store'), \array_merge( + $this->skeleton, + [ + 'brand_id' => 0, + 'subject_id' => 0, + 'customer_id' => 0, + ] + )); + $json = $response->decodeResponseJson(); + $this->assertApiResponseStatusIs($json, ApiStatus::KO); + $this->assertEquals(ApiError::validationFailed->value(), $json->json('data.code')); + } + + /** + * Test save claim without optionnal fields should work. + * route: apiV4.claim.store + * + * @return void + */ + public function testSendClaimWithoutOptionnalFieldsShouldWork(): void + { + extract($this->getCustomer(true, false)); + $subject = ClaimSubject::query()->firstOrNew(); + $customer = Customer::query()->firstOrNew(); + + $response = $this->callApiWithToken($service, 'post', route('apiV4.claim.store'), \array_merge( + Arr::except($this->skeleton, ['address', 'city', 'postcode', 'file']), + [ + 'brand_id' => $brand->getKey(), + 'subject_id' => $subject->getKey(), + ] + )); + $claimModel = Claim::query()->where([ + ['email', 'claim@hotmail.fr'], + ['brand_id', $brand->getKey()], + ['subject_id', $subject->getKey()], + ['customer_id', null], + ])->exists(); + $json = $response->decodeResponseJson(); + $this->assertApiResponseStatusIs($json, ApiStatus::OK); + $this->assertTrue($claimModel, 'Claim should have been stored.'); + } + + /** + * Test save claim with wrong file format should fail. + * route: apiV4.claim.store + * + * @return void + */ + public function testSendClaimWithWrongFileFormatShouldFail(): void + { + extract($this->getCustomer(true, false)); + $subject = ClaimSubject::query()->firstOrNew(); + $customer = Customer::query()->firstOrNew(); + + $response = $this->callApiWithToken($service, 'post', route('apiV4.claim.store'), \array_merge( + Arr::except($this->skeleton, ['address', 'city', 'postcode', 'file']), + [ + 'file' => \Illuminate\Http\UploadedFile::fake()->create('x.gif', 100, 'image/gif'), + 'brand_id' => $brand->getKey(), + 'subject_id' => $subject->getKey(), + 'customer_id' => $customer->getKey(), + ] + )); + $json = $response->decodeResponseJson(); + $this->assertApiResponseStatusIs($json, ApiStatus::KO); + $this->assertEquals(ApiError::validationFailed->value(), $json->json('data.code')); + } +} diff --git a/tests/Client/CrmClientRouterTest.php b/tests/Client/CrmClientRouterTest.php index a2970e7..9bb52a5 100644 --- a/tests/Client/CrmClientRouterTest.php +++ b/tests/Client/CrmClientRouterTest.php @@ -8,11 +8,11 @@ use LDC\LDCCRM\Utils; class CrmClientRouterTest extends CrmClientTester { /** - * Test all Routes + * Test all routes. * * @return void */ - public function testRoutesGet() + public function testRoutesGet(): void { $routes = $this->getClientRoutes(); @@ -35,7 +35,7 @@ class CrmClientRouterTest extends CrmClientTester * * @return void */ - public function testGenRequest() + public function testGenRequest(): void { $this->expectNotToPerformAssertions(); $routes = $this->getClientRoutes(); From ced124b60e14d07f20b90a96b6d9c017ad3b9773 Mon Sep 17 00:00:00 2001 From: Alexis Gousseau Date: Mon, 28 Jul 2025 09:46:22 +0200 Subject: [PATCH 03/11] feat: :sparkles: add claims bo interface --- app/Console/Commands/UserCreate.php | 12 +- app/Enums/Claims/ClaimMessageType.php | 8 +- app/Enums/Claims/ClaimResponseType.php | 51 + app/Enums/Claims/ClaimStatus.php | 28 +- app/Enums/Claims/ClaimType.php | 19 + app/Enums/Users/RoleEnum.php | 4 +- app/Events/ClaimModelChanged.php | 55 + .../Controllers/Bo/ActivityLogsController.php | 8 + app/Http/Controllers/Bo/AnswerController.php | 8 + app/Http/Controllers/Bo/BrandController.php | 22 +- app/Http/Controllers/Bo/ClaimController.php | 189 +++ .../Controllers/Bo/ClaimMessageController.php | 54 + .../Controllers/Bo/CustomerController.php | 9 + .../Controllers/Bo/QuestionController.php | 25 +- app/Http/Controllers/Bo/ServiceController.php | 22 +- .../Controllers/Bo/SingleOptinController.php | 8 + app/Http/Controllers/Bo/StatsController.php | 9 +- ...UsersController.php => UserController.php} | 2 +- app/Http/Controllers/Controller.php | 28 +- .../Bo/ClaimMessages/StoreMessageRequest.php | 66 + .../Bo/ClaimMessages/UpdateMessageRequest.php | 44 + .../Bo/Claims/SendClaimAnswerRequest.php | 44 + .../Requests/Bo/Claims/UpdateClaimRequest.php | 54 + .../Requests/Bo/PaginateModelsRequest.php | 52 + .../Bo/Questions/StoreQuestionRequest.php | 12 - .../Bo/Services/StoreServiceRequest.php | 12 - app/Http/Requests/Bo/ThemeRequest.php | 34 + .../Requests/Bo/Users/UpdateUserRequest.php | 8 +- app/Listeners/AddClaimMessageSystem.php | 123 ++ app/Mail/ClaimAnswerMail.php | 70 + app/Models/Claim.php | 111 +- app/Models/ClaimMessage.php | 18 + app/Policies/ActivityLogPolicy.php | 32 + app/Policies/AnswerPolicy.php | 26 +- app/Policies/BrandPolicy.php | 23 +- app/Policies/ClaimMessagePolicy.php | 51 + app/Policies/ClaimPolicy.php | 105 ++ app/Policies/CustomerPolicy.php | 34 +- app/Policies/QuestionPolicy.php | 40 +- app/Policies/ServicePolicy.php | 26 +- app/Policies/SingleOptinPolicy.php | 20 +- app/Policies/StatisticPolicy.php | 43 + app/Policies/UserPolicy.php | 18 +- app/Providers/AuthServiceProvider.php | 5 + app/Providers/EventServiceProvider.php | 7 +- database/factories/ClaimFactory.php | 26 +- database/factories/UserFactory.php | 15 +- .../2025_07_24_113251_create_claims_table.php | 7 +- ...2025_07_25_112127_alter_users_for_saml.php | 2 +- package-lock.json | 117 +- package.json | 2 + resources/assets/images/logo_ldc.jpg | Bin 0 -> 8795 bytes resources/assets/images/logo_ldc.png | Bin 6686 -> 0 bytes resources/lang/en/models.php | 42 +- resources/lang/en/validation.php | 16 +- resources/lang/fr/models.php | 42 +- resources/lang/fr/validation.php | 16 +- resources/sass/bo/base/_common.scss | 8 + resources/sass/bo/bo.scss | 4 - resources/sass/bo/pages/.gitkeep | 0 resources/sass/bo/partials/.gitkeep | 0 resources/sass/bo/vendor/_bootstrap.scss | 1 + .../BelongsToManyDropdownComponent.vue | 255 ---- .../bo/components/ClaimActionsComponent.vue | 494 +++++++ .../components/ClaimConversationComponent.vue | 263 ++++ .../ClaimManualResponseComponent.vue | 271 ++++ .../ClaimMessageCollapseComponent.vue | 98 ++ .../bo/components/ClaimMessageComponent.vue | 346 +++++ .../bo/components/ClaimWrapperComponent.vue | 123 ++ .../ts/bo/components/ImageInputComponent.vue | 1289 +++++++++-------- .../SearchBelongsToDropdownComponent.vue | 504 +++++++ resources/ts/bo/utilities/bootstrap.ts | 4 +- resources/ts/bo/utilities/fontawesome.ts | 100 +- resources/ts/fo/utilities/bootstrap.ts | 4 +- resources/ts/index.d.ts | 22 +- resources/ts/modules/bsTooltips.ts | 26 - ...parseLaravelErrorMessages.ts => errors.ts} | 29 +- resources/ts/modules/route.ts | 13 + resources/ts/modules/tooltips.ts | 114 ++ resources/views/bo/layouts/header.blade.php | 24 +- resources/views/bo/layouts/nav-list.blade.php | 58 +- resources/views/bo/layouts/sidenav.blade.php | 63 +- .../bo/modules/change-model-order.blade.php | 6 +- .../modules/change-published-status.blade.php | 4 +- .../views/bo/modules/pagination.blade.php | 45 +- .../bo/modules/search-bar-brand.blade.php | 74 - .../views/bo/modules/search-bar.blade.php | 121 +- .../bo/modules/table-col-sorter.blade.php | 8 +- .../pages/activity_logs/index-list.blade.php | 6 +- .../bo/pages/activity_logs/index.blade.php | 28 +- .../bo/pages/activity_logs/show.blade.php | 6 +- .../views/bo/pages/answers/create.blade.php | 6 +- .../views/bo/pages/answers/edit.blade.php | 8 +- .../bo/pages/answers/index-list.blade.php | 102 +- .../views/bo/pages/answers/index.blade.php | 10 +- .../views/bo/pages/brands/create.blade.php | 6 +- .../views/bo/pages/brands/edit.blade.php | 6 +- .../bo/pages/brands/index-list.blade.php | 84 +- .../views/bo/pages/brands/index.blade.php | 6 +- .../views/bo/pages/claims/edit.blade.php | 94 ++ .../bo/pages/claims/index-list.blade.php | 75 + .../views/bo/pages/claims/index.blade.php | 39 + .../views/bo/pages/claims/preview.blade.php | 39 + .../views/bo/pages/customers/export.blade.php | 4 +- .../bo/pages/customers/index-list.blade.php | 84 +- .../customers/index-tableHeaders.blade.php | 315 ++-- .../views/bo/pages/customers/index.blade.php | 7 +- .../views/bo/pages/customers/show.blade.php | 4 +- resources/views/bo/pages/dashboard.blade.php | 2 +- .../views/bo/pages/questions/create.blade.php | 6 +- .../views/bo/pages/questions/edit.blade.php | 10 +- .../views/bo/pages/questions/export.blade.php | 4 +- .../views/bo/pages/questions/form.blade.php | 31 +- .../bo/pages/questions/index-list.blade.php | 136 +- .../views/bo/pages/questions/index.blade.php | 8 +- .../views/bo/pages/questions/show.blade.php | 18 +- .../views/bo/pages/services/create.blade.php | 6 +- .../views/bo/pages/services/edit.blade.php | 6 +- .../views/bo/pages/services/form.blade.php | 31 +- .../bo/pages/services/index-list.blade.php | 124 +- .../views/bo/pages/services/index.blade.php | 8 +- .../views/bo/pages/services/show.blade.php | 2 +- .../pages/singleoptins/index-list.blade.php | 88 +- .../bo/pages/singleoptins/index.blade.php | 6 +- .../views/bo/pages/users/create.blade.php | 6 +- resources/views/bo/pages/users/edit.blade.php | 10 +- .../views/bo/pages/users/index-list.blade.php | 8 +- .../views/bo/pages/users/index.blade.php | 44 +- .../search-belongs-to-dropdown.blade.php | 29 + .../bo/partials/inputs/tinyint-enum.blade.php | 6 +- .../bo/partials/inputs/varchar-file.blade.php | 2 +- .../components/bo/claims/enum-badge.blade.php | 7 + resources/views/fo/layouts/nav-menu.blade.php | 2 +- .../mail/send-claim-answer-plain.blade.php | 19 + .../views/mail/send-claim-answer.blade.php | 38 + resources/views/modules/input-error.blade.php | 10 +- .../modules/minicrud-form-inputs.blade.php | 4 +- .../views/modules/script-routes.blade.php | 15 +- resources/views/vendor/errors/403.blade.php | 2 +- resources/views/vendor/errors/404.blade.php | 2 +- resources/views/vendor/errors/503.blade.php | 3 +- .../mail/html/footer-claim-answer.blade.php | 11 + .../mail/html/header-claim-answer.blade.php | 7 + .../views/vendor/mail/html/header.blade.php | 6 +- routes/api.php | 4 - routes/breadcrumbs-bo.php | 9 + routes/web-bo.php | 43 +- routes/web-fo.php | 2 +- 148 files changed, 5893 insertions(+), 2106 deletions(-) create mode 100644 app/Enums/Claims/ClaimResponseType.php create mode 100644 app/Events/ClaimModelChanged.php create mode 100644 app/Http/Controllers/Bo/ClaimController.php create mode 100644 app/Http/Controllers/Bo/ClaimMessageController.php rename app/Http/Controllers/Bo/{UsersController.php => UserController.php} (99%) create mode 100644 app/Http/Requests/Bo/ClaimMessages/StoreMessageRequest.php create mode 100644 app/Http/Requests/Bo/ClaimMessages/UpdateMessageRequest.php create mode 100644 app/Http/Requests/Bo/Claims/SendClaimAnswerRequest.php create mode 100644 app/Http/Requests/Bo/Claims/UpdateClaimRequest.php create mode 100644 app/Http/Requests/Bo/PaginateModelsRequest.php create mode 100644 app/Http/Requests/Bo/ThemeRequest.php create mode 100644 app/Listeners/AddClaimMessageSystem.php create mode 100644 app/Mail/ClaimAnswerMail.php create mode 100644 app/Policies/ActivityLogPolicy.php create mode 100644 app/Policies/ClaimMessagePolicy.php create mode 100644 app/Policies/ClaimPolicy.php create mode 100644 app/Policies/StatisticPolicy.php create mode 100644 resources/assets/images/logo_ldc.jpg delete mode 100644 resources/assets/images/logo_ldc.png delete mode 100644 resources/sass/bo/pages/.gitkeep delete mode 100644 resources/sass/bo/partials/.gitkeep delete mode 100644 resources/ts/bo/components/BelongsToManyDropdownComponent.vue create mode 100644 resources/ts/bo/components/ClaimActionsComponent.vue create mode 100644 resources/ts/bo/components/ClaimConversationComponent.vue create mode 100644 resources/ts/bo/components/ClaimManualResponseComponent.vue create mode 100644 resources/ts/bo/components/ClaimMessageCollapseComponent.vue create mode 100644 resources/ts/bo/components/ClaimMessageComponent.vue create mode 100644 resources/ts/bo/components/ClaimWrapperComponent.vue create mode 100644 resources/ts/bo/components/SearchBelongsToDropdownComponent.vue delete mode 100644 resources/ts/modules/bsTooltips.ts rename resources/ts/modules/{parseLaravelErrorMessages.ts => errors.ts} (59%) create mode 100644 resources/ts/modules/tooltips.ts delete mode 100644 resources/views/bo/modules/search-bar-brand.blade.php create mode 100644 resources/views/bo/pages/claims/edit.blade.php create mode 100644 resources/views/bo/pages/claims/index-list.blade.php create mode 100644 resources/views/bo/pages/claims/index.blade.php create mode 100644 resources/views/bo/pages/claims/preview.blade.php create mode 100644 resources/views/bo/partials/inputs/search-belongs-to-dropdown.blade.php create mode 100644 resources/views/components/bo/claims/enum-badge.blade.php create mode 100644 resources/views/mail/send-claim-answer-plain.blade.php create mode 100644 resources/views/mail/send-claim-answer.blade.php create mode 100644 resources/views/vendor/mail/html/footer-claim-answer.blade.php create mode 100644 resources/views/vendor/mail/html/header-claim-answer.blade.php diff --git a/app/Console/Commands/UserCreate.php b/app/Console/Commands/UserCreate.php index d9cee85..bafeb10 100644 --- a/app/Console/Commands/UserCreate.php +++ b/app/Console/Commands/UserCreate.php @@ -173,12 +173,12 @@ class UserCreate extends Command $tmp = $this->choice( 'Select his role', [ - RoleEnum::conceptor->name, - RoleEnum::admin->name, - RoleEnum::visitor->name, - RoleEnum::marketing->name, + Str::ucFirst(RoleEnum::conceptor->label()), + Str::ucFirst(RoleEnum::admin->label()), + Str::ucFirst(RoleEnum::visitor->label()), + Str::ucFirst(RoleEnum::marketing->label()) ], - RoleEnum::visitor->name, + Str::ucFirst(RoleEnum::marketing->label()), ); if ($tmp === Str::ucFirst(RoleEnum::conceptor->label())) { $tmp = RoleEnum::conceptor; @@ -189,7 +189,7 @@ class UserCreate extends Command if ($tmp === Str::ucFirst(RoleEnum::visitor->label())) { $tmp = RoleEnum::visitor; } - if ($tmp === RoleEnum::marketing->name) { + if ($tmp === Str::ucFirst(RoleEnum::marketing->label())) { $tmp = RoleEnum::marketing; } $validator = Validator::make(['role' => $tmp], [ diff --git a/app/Enums/Claims/ClaimMessageType.php b/app/Enums/Claims/ClaimMessageType.php index 5c2aef9..3b2e965 100644 --- a/app/Enums/Claims/ClaimMessageType.php +++ b/app/Enums/Claims/ClaimMessageType.php @@ -8,14 +8,14 @@ enum ClaimMessageType: int { use BaseEnum; - case auto = 1; - case human = 2; + case system = 1; + case human = 2; /** * Optionnal labels definition */ private const LABELS = [ - self::auto->name => 'Automatique', - self::human->name => 'Humain', + self::system->name => 'Système', + self::human->name => 'Humain', ]; } diff --git a/app/Enums/Claims/ClaimResponseType.php b/app/Enums/Claims/ClaimResponseType.php new file mode 100644 index 0000000..c8575eb --- /dev/null +++ b/app/Enums/Claims/ClaimResponseType.php @@ -0,0 +1,51 @@ +name => 'Non défini', + self::manual->name => 'Manuelle', + self::mail->name => 'Courrier', + self::email->name => 'E-mail', + self::phone->name => 'Téléphone', + self::other->name => 'Autre', + ]; + + /** + * Optionnal labels definition. + */ + private const COLORS = [ + self::none->name => '#b8b8b8', + self::manual->name => '#a7a7a7', + self::mail->name => '#757575', + self::email->name => '#5e5e5e', + self::phone->name => '#414141', + self::other->name => '#2b2b2b', + ]; + + /** + * Get Class. + * + * @return string + */ + public function color(): string + { + return self::COLORS[$this->name]; + } +} diff --git a/app/Enums/Claims/ClaimStatus.php b/app/Enums/Claims/ClaimStatus.php index 068a16d..29ca37b 100644 --- a/app/Enums/Claims/ClaimStatus.php +++ b/app/Enums/Claims/ClaimStatus.php @@ -9,17 +9,37 @@ enum ClaimStatus: int use BaseEnum; case untreated = 1; - case treated = 2; - case sentDigital = 3; - case sentMarketing = 4; + case sentDigital = 2; + case sentMarketing = 3; + case treated = 4; /** * Optionnal labels definition */ private const LABELS = [ self::untreated->name => 'Non traitée', - self::treated->name => 'Traitée', self::sentDigital->name => 'Transférée au service Digital', self::sentMarketing->name => 'Retournée au Marketing', + self::treated->name => 'Traitée', ]; + + /** + * Optionnal labels definition. + */ + private const COLORS = [ + self::untreated->name => '#5a5a5a', + self::sentDigital->name => '#0033c0', + self::sentMarketing->name => '#69077c', + self::treated->name => '#188618', + ]; + + /** + * Get Class. + * + * @return string + */ + public function color(): string + { + return self::COLORS[$this->name]; + } } diff --git a/app/Enums/Claims/ClaimType.php b/app/Enums/Claims/ClaimType.php index c44bd65..bab2dca 100644 --- a/app/Enums/Claims/ClaimType.php +++ b/app/Enums/Claims/ClaimType.php @@ -20,4 +20,23 @@ enum ClaimType: int self::br->name => 'BR', self::rgpd->name => 'RGPD', ]; + + /** + * Optionnal labels definition. + */ + private const COLORS = [ + self::classic->name => '#08818a', + self::br->name => '#9021f8', + self::rgpd->name => '#c2237a', + ]; + + /** + * Get Class. + * + * @return string + */ + public function color(): string + { + return self::COLORS[$this->name]; + } } diff --git a/app/Enums/Users/RoleEnum.php b/app/Enums/Users/RoleEnum.php index 4a30c1e..b72f1cb 100644 --- a/app/Enums/Users/RoleEnum.php +++ b/app/Enums/Users/RoleEnum.php @@ -10,8 +10,7 @@ enum RoleEnum: int case conceptor = 1; case admin = 2; - case visitor = 3; - case marketing = 4; + case marketing = 3; /** * Optionnal labels definition. @@ -19,7 +18,6 @@ enum RoleEnum: int private const LABELS = [ self::conceptor->name => 'Concepteur', self::admin->name => 'Administrateur', - self::visitor->name => 'Visiteur', self::marketing->name => 'Marketing', ]; } diff --git a/app/Events/ClaimModelChanged.php b/app/Events/ClaimModelChanged.php new file mode 100644 index 0000000..9b0b937 --- /dev/null +++ b/app/Events/ClaimModelChanged.php @@ -0,0 +1,55 @@ +claim = $claim; + $this->field = $field; + $this->label = $label; + $this->user = $user; + $this->content = $content; + } +} diff --git a/app/Http/Controllers/Bo/ActivityLogsController.php b/app/Http/Controllers/Bo/ActivityLogsController.php index 7dbf191..a88b9ef 100644 --- a/app/Http/Controllers/Bo/ActivityLogsController.php +++ b/app/Http/Controllers/Bo/ActivityLogsController.php @@ -13,6 +13,14 @@ class ActivityLogsController extends Controller use ChangesModelOrder; use UpdateModelPublished; + /** + * Create the controller instance. + */ + public function __construct() + { + $this->authorizeResource(ActivityLog::class); + } + /** * Display a listing of the resource. * diff --git a/app/Http/Controllers/Bo/AnswerController.php b/app/Http/Controllers/Bo/AnswerController.php index c44b595..074d1a8 100644 --- a/app/Http/Controllers/Bo/AnswerController.php +++ b/app/Http/Controllers/Bo/AnswerController.php @@ -13,6 +13,14 @@ use Illuminate\Support\Str; class AnswerController extends Controller { + /** + * Create the controller instance. + */ + public function __construct() + { + $this->authorizeResource(Answer::class); + } + /** * Display a listing of the resource. * diff --git a/app/Http/Controllers/Bo/BrandController.php b/app/Http/Controllers/Bo/BrandController.php index d70e1d9..c8accf0 100644 --- a/app/Http/Controllers/Bo/BrandController.php +++ b/app/Http/Controllers/Bo/BrandController.php @@ -13,6 +13,14 @@ use Illuminate\Support\Str; class BrandController extends Controller { + /** + * Create the controller instance. + */ + public function __construct() + { + $this->authorizeResource(Brand::class); + } + /** * Display a listing of the resource. * @@ -126,18 +134,4 @@ class BrandController extends Controller )); }); } - - /** - * Store a newly created resource in storage. - * - * @return \Illuminate\Http\JsonResponse - */ - public function jsonPaginate(): \Illuminate\Http\JsonResponse - { - return DB::transaction(function () { - /** @var \App\Models\Brand */ - $brandModels = Brand::paginate(12); - return \response()->json($brandModels ?? 500); - }); - } } diff --git a/app/Http/Controllers/Bo/ClaimController.php b/app/Http/Controllers/Bo/ClaimController.php new file mode 100644 index 0000000..a617b01 --- /dev/null +++ b/app/Http/Controllers/Bo/ClaimController.php @@ -0,0 +1,189 @@ +authorizeResource(Claim::class); + } + + /** + * Display a listing of the resource. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Contracts\View\View + */ + public function index(Request $request): \Illuminate\Contracts\View\View + { + /** @var \Illuminate\Database\Eloquent\Builder $claimModels */ + $claimModels = Claim::query()->when( + $request->filled('brand'), + fn($q) => $q->whereHas('brand', fn($q) => $q->where('id', $request->brand)) + ); + + /** @var string $search Search field */ + $search = $request->search; + if ($search) { + $this->searchQuery( + $claimModels, + $search, + null, + 'first_name', + 'last_name', + 'email', + ); + } + $searchFields = \implode(', ', [ + trans('validation.attributes.first_name'), + trans('validation.attributes.last_name'), + trans('validation.attributes.email'), + ]); + + /** Sort columns with a query */ + $this->sortQuery($claimModels); + + /** Custom pagination */ + $claimModels = $this->paginate($claimModels); + + return view('bo.pages.claims.index', compact('claimModels', 'search', 'searchFields')); + } + + /** + * Show the form for editing the specified resource. + * + * @param App\Models\Claim $claim + * @return \Illuminate\Contracts\View\View + */ + public function edit(Claim $claim): \Illuminate\Contracts\View\View + { + $customerClaimModels = !is_null($claim->customer) ? $this->paginate(Claim::query() + ->whereNotNull('customer_id') + ->whereHas('brand', fn($q) => $q->whereKey($claim->brand->getKey())) + ->whereHas('customer', fn($q) => $q->whereKey($claim->customer->getKey())) + ->whereNot('id', $claim->getKey()) + ->whereNot('status', ClaimStatus::treated)) : collect(); + $brandModels = Brand::query()->orderBy('name', 'ASC')->paginate($this->jsonItemPerPagination); + $claimSubjectModels = ClaimSubject::query() + ->whereHas('brand', fn($q) => $q->whereKey($claim->brand->getKey())) + ->orderBy('label', 'ASC') + ->paginate($this->jsonItemPerPagination); + $claimMessageModels = ClaimMessage::getAllClaimMessages($claim->getKey()); + $claimTemplateModels = ClaimMailTemplate::query() + ->whereHas('brand', fn($q) => $q->whereKey($claim->brand->getKey())) + ->orderBy('label', 'ASC') + ->paginate($this->jsonItemPerPagination); + + return view('bo.pages.claims.edit', [ + 'claimModel' => $claim->load(['brand', 'claimSubject']), + 'customerClaimModels' => $customerClaimModels, + 'brandModels' => $brandModels, + 'claimSubjectModels' => $claimSubjectModels, + 'claimMessageModels' => $claimMessageModels, + 'claimTemplateModels' => $claimTemplateModels, + ]); + } + + /** + * Update the specified resource. + * + * @param \App\Http\Requests\Bo\Claims\UpdateClaimRequest $request + * @param \App\Models\Claim $claim + * @return \Illuminate\Http\JsonResponse + */ + public function update(UpdateClaimRequest $request, Claim $claim): \Illuminate\Http\JsonResponse + { + return DB::transaction(function () use ($request, $claim) { + $claim->fill($request->validated()); + + if ($claim->saveOrFail()) { + $claimMessageModels = ClaimMessage::getAllClaimMessages($claim->getKey()); + return response()->json($claimMessageModels); + } + return response()->json([], 500); + }); + } + + /** + * Get a paginate resource. + * Needed to overheight the controller method and add a brand condition. + * + * @param \App\Http\Requests\Bo\PaginateModelsRequest $request + * @return \Illuminate\Http\JsonResponse + */ + public function jsonClaimPaginateModels(PaginateModelsRequest $request): \Illuminate\Http\JsonResponse + { + /** @var \Illuminate\Database\Eloquent\Model $models */ + $models = $request->targetModel::query() + ->whereHas('brand', fn($q) => $q->whereKey($request->route()->parameter('brand'))) + ->where($request->input('fieldName') ?? 'name', 'like', "%{$request->input('search')}%") + ->orderBy($request->input('fieldName') ?? 'name', 'ASC') + ->paginate($request->input('paginate') ?? 10); + return \response()->json($models); + } + + /** + * Send the claim answer. + * + * @param \App\Http\Requests\Bo\Claims\SendClaimAnswerRequest $request + * @param \App\Models\Claim $claim + * @return \Illuminate\Http\JsonResponse + */ + public function answer(SendClaimAnswerRequest $request, Claim $claim): \Illuminate\Http\JsonResponse + { + return DB::transaction(function () use ($request, $claim) { + /** @var \App\Models\User $userModel */ + $userModel = auth()->user(); + $enum = ClaimResponseType::manual; + $claim->response_type = $enum; + $claim->status = ClaimStatus::treated; + + if ($claim->saveOrFail()) { + // Send the response to the claim author. + Mail::to($claim->email)->send(new ClaimAnswerMail($claim, $request->validated()['content'])); + + // Create custom event with content message. + // @phpcs:disable Generic.Files.LineLength.TooLong + $content = sprintf( + "%s %s %s %s
%s", + $userModel->first_name, + $userModel->last_name, + trans('a modifié le :field en', ['field' => trans('validation.custom.response_type')]), + $claim->response_type->label(), + clean($request->validated()['content']), + ); + event(new ClaimModelChanged($claim, '', '', null, $content)); + // @phpcs:enable + + // Return conversation. + $claimMessageModels = ClaimMessage::getAllClaimMessages($claim->getKey()); + return response()->json($claimMessageModels); + } //end if + return response()->json([], 500); + }); + } +} diff --git a/app/Http/Controllers/Bo/ClaimMessageController.php b/app/Http/Controllers/Bo/ClaimMessageController.php new file mode 100644 index 0000000..2d8660f --- /dev/null +++ b/app/Http/Controllers/Bo/ClaimMessageController.php @@ -0,0 +1,54 @@ +authorize('store', ClaimMessage::class); + + return DB::transaction(function () use ($request) { + $claimMessage = new ClaimMessage(); + $claimMessage->fill($request->validated()); + if ($claimMessage->saveOrFail()) { + $claimMessageModels = ClaimMessage::getAllClaimMessages($claimMessage->claim->getKey()); + return response()->json($claimMessageModels); + } + return response()->json([], 500); + }); + } + + /** + * Update a specified resource. + * + * @param \App\Http\Requests\Bo\ClaimMessages\UpdateMessageRequest $request + * @param \App\Models\ClaimMessage $claim_message + * @return \Illuminate\Http\JsonResponse + */ + public function update(UpdateMessageRequest $request, ClaimMessage $claim_message): \Illuminate\Http\JsonResponse + { + $this->authorize('update', ClaimMessage::class); + + $model = ClaimMessage::findOrFail($claim_message->getKey()); + $model->content = $request->validated()['content']; + $model->saveOrFail(); + + return response()->json(); + } +} diff --git a/app/Http/Controllers/Bo/CustomerController.php b/app/Http/Controllers/Bo/CustomerController.php index c1f3ec3..4050a3c 100644 --- a/app/Http/Controllers/Bo/CustomerController.php +++ b/app/Http/Controllers/Bo/CustomerController.php @@ -23,6 +23,14 @@ use Symfony\Component\HttpFoundation\StreamedResponse; class CustomerController extends Controller { + /** + * Create the controller instance. + */ + public function __construct() + { + $this->authorizeResource(Customer::class); + } + /** * View all customers. * @@ -195,6 +203,7 @@ class CustomerController extends Controller */ public function export(): \Illuminate\Contracts\View\View { + $this->authorize('export', Customer::class); $brands = Brand::all(); return view('bo.pages.customers.export', compact( 'brands' diff --git a/app/Http/Controllers/Bo/QuestionController.php b/app/Http/Controllers/Bo/QuestionController.php index 81d6e49..3ed8a48 100644 --- a/app/Http/Controllers/Bo/QuestionController.php +++ b/app/Http/Controllers/Bo/QuestionController.php @@ -18,6 +18,14 @@ use Symfony\Component\HttpFoundation\StreamedResponse; class QuestionController extends Controller { + /** + * Create the controller instance. + */ + public function __construct() + { + $this->authorizeResource(Question::class); + } + /** * Display a listing of the resource. * @@ -27,11 +35,11 @@ class QuestionController extends Controller public function index(Request $request): \Illuminate\Contracts\View\View { /** @var \Illuminate\Database\Eloquent\Builder $query */ - $query = Question::query(); + $query = Question::query()->when( + $request->filled('brand'), + fn($q) => $q->whereHas('brand', fn($q) => $q->where('id', $request->brand)) + ); - if ($request->brand) { - $query = $query->where('brand_id', '=', $request->brand); - } if ($request->search) { $this->searchQuery( $query, @@ -60,11 +68,10 @@ class QuestionController extends Controller */ public function create(Question $question): \Illuminate\Contracts\View\View { - $brandModels = Brand::all(); - + $brandModels = Brand::query()->orderBy('name', 'ASC')->paginate($this->jsonItemPerPagination); return view('bo.pages.questions.create', [ 'questionModel' => $question, - 'brandModels' => $brandModels + 'brandModels' => $brandModels ]); } @@ -104,9 +111,8 @@ class QuestionController extends Controller */ public function edit(Question $question): \Illuminate\Contracts\View\View { - $brandModels = Brand::all(); + $brandModels = Brand::query()->orderBy('name', 'ASC')->paginate($this->jsonItemPerPagination); $question->load('brand'); - return view('bo.pages.questions.edit', [ 'questionModel' => $question, 'brandModels' => $brandModels @@ -183,6 +189,7 @@ class QuestionController extends Controller */ public function export(): \Illuminate\Contracts\View\View { + $this->authorize('export', Question::class); $brands = Brand::all(); return view('bo.pages.questions.export', compact('brands')); } diff --git a/app/Http/Controllers/Bo/ServiceController.php b/app/Http/Controllers/Bo/ServiceController.php index d7b5270..001bd42 100644 --- a/app/Http/Controllers/Bo/ServiceController.php +++ b/app/Http/Controllers/Bo/ServiceController.php @@ -17,6 +17,14 @@ use Illuminate\Support\Str; class ServiceController extends Controller { + /** + * Create the controller instance. + */ + public function __construct() + { + $this->authorizeResource(Service::class); + } + /** * Display a listing of the resource. * @@ -26,11 +34,11 @@ class ServiceController extends Controller public function index(Request $request): \Illuminate\Contracts\View\View { /** @var \Illuminate\Database\Eloquent\Builder $query */ - $query = Service::query(); + $query = Service::query()->when( + $request->filled('brand'), + fn($q) => $q->whereHas('brand', fn($q) => $q->where('id', $request->brand)) + ); - if ($request->brand) { - $query = $query->where('brand_id', '=', $request->brand); - } if ($request->search) { $this->searchQuery( $query, @@ -58,8 +66,7 @@ class ServiceController extends Controller */ public function create(Service $service): \Illuminate\Contracts\View\View { - $brandModels = Brand::all(); - + $brandModels = Brand::query()->orderBy('name', 'ASC')->paginate($this->jsonItemPerPagination); return view('bo.pages.services.create', [ 'serviceModel' => $service, 'brandModels' => $brandModels @@ -104,8 +111,7 @@ class ServiceController extends Controller */ public function edit(Service $service): \Illuminate\Contracts\View\View { - $brandModels = Brand::all(); - + $brandModels = Brand::query()->orderBy('name', 'ASC')->paginate($this->jsonItemPerPagination); return view('bo.pages.services.edit', [ 'serviceModel' => $service, 'brandModels' => $brandModels diff --git a/app/Http/Controllers/Bo/SingleOptinController.php b/app/Http/Controllers/Bo/SingleOptinController.php index f34b86c..f2fdfbe 100644 --- a/app/Http/Controllers/Bo/SingleOptinController.php +++ b/app/Http/Controllers/Bo/SingleOptinController.php @@ -11,6 +11,14 @@ use Illuminate\Support\Str; class SingleOptinController extends Controller { + /** + * Create the controller instance. + */ + public function __construct() + { + $this->authorizeResource(SingleOptin::class); + } + /** * Display a listing of the resource. * diff --git a/app/Http/Controllers/Bo/StatsController.php b/app/Http/Controllers/Bo/StatsController.php index dd2aecb..4b35f52 100644 --- a/app/Http/Controllers/Bo/StatsController.php +++ b/app/Http/Controllers/Bo/StatsController.php @@ -7,10 +7,11 @@ use App\Http\Requests\Bo\StatsByBrandRequest; use App\Http\Requests\Bo\StatsByQuestionRequest; use App\Models\Brand; use App\Models\BrandStat; -use App\Models\CustomerAnswer; +use App\Models\ModelAnswer; use App\Models\Question; use Illuminate\Support\Carbon; use Illuminate\Support\Collection; +use Illuminate\Support\Facades\Gate; use Illuminate\Support\Facades\Schema; use League\Csv\Writer; @@ -24,6 +25,7 @@ class StatsController extends Controller */ public function viewStatsByBrand(StatsByBrandRequest $request) { + Gate::authorize('viewStatsByBrand'); $stats = null; if ($request->post()) { $stats = BrandStat::query()->whereDate('created_at', '>=', $request->start) @@ -85,6 +87,7 @@ class StatsController extends Controller */ public function viewByQuestion(StatsByQuestionRequest $request): \Illuminate\Contracts\View\View { + Gate::authorize('viewByQuestion'); $question = null; $answers = null; $answersByDays = null; @@ -152,8 +155,10 @@ class StatsController extends Controller */ private function answersByDays(Collection $answers, Carbon $start, Carbon $end): \Illuminate\Support\Collection { + Gate::authorize('answersByDays'); // * Totalize by date all answers. - $answersByDays = CustomerAnswer::query()->whereDate('created_at', '>=', $start) + $answersByDays = ModelAnswer::query() + ->whereDate('created_at', '>=', $start) ->whereDate('created_at', '<=', $end) ->whereIn('answer_id', $answers->pluck('id')) ->get()->map(function ($custAnswer) { diff --git a/app/Http/Controllers/Bo/UsersController.php b/app/Http/Controllers/Bo/UserController.php similarity index 99% rename from app/Http/Controllers/Bo/UsersController.php rename to app/Http/Controllers/Bo/UserController.php index 1613af2..72f632e 100644 --- a/app/Http/Controllers/Bo/UsersController.php +++ b/app/Http/Controllers/Bo/UserController.php @@ -11,7 +11,7 @@ use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; use Illuminate\Support\Str; -class UsersController extends Controller +class UserController extends Controller { use UpdateModelPublished; diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 768c25f..e083748 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -4,11 +4,12 @@ namespace App\Http\Controllers; use App\Enums\Pagination\ItemsPerPaginationEnum; use App\Enums\Theme\BootstrapThemeEnum; +use App\Http\Requests\Bo\PaginateModelsRequest; +use App\Http\Requests\Bo\ThemeRequest; use App\Lib\Helpers\ToolboxHelper; use Illuminate\Database\Eloquent\Builder; use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use Illuminate\Foundation\Validation\ValidatesRequests; -use Illuminate\Http\Request; use Illuminate\Routing\Controller as BaseController; use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Schema; @@ -20,6 +21,9 @@ class Controller extends BaseController use AuthorizesRequests; use ValidatesRequests; + /** @var integer $itemPerPagination */ + public $jsonItemPerPagination = 5; + /** * Build Search query on specified fields * splitting search into words or using whole sentence @@ -210,16 +214,32 @@ class Controller extends BaseController return $query; } + /** + * Get a paginate resource. + * + * @param \App\Http\Requests\Bo\PaginateModelsRequest $request + * @return \Illuminate\Http\JsonResponse + */ + public function jsonPaginateModels(PaginateModelsRequest $request): \Illuminate\Http\JsonResponse + { + /** @var \Illuminate\Database\Eloquent\Model $models */ + $models = $request->targetModel::query() + ->where($request->input('fieldName') ?? 'name', 'like', "%{$request->input('search')}%") + ->orderBy($request->input('fieldName') ?? 'name', 'ASC') + ->paginate($request->input('paginate') ?? 10); + return \response()->json($models); + } + /** * Set the bootstrap theme or light (default). * - * @param \Illuminate\Http\Request $request + * @param \App\Http\Requests\Bo\ThemeRequest $request * @return \Illuminate\Http\RedirectResponse */ - protected function setTheme(Request $request): \Illuminate\Http\RedirectResponse + protected function setTheme(ThemeRequest $request): \Illuminate\Http\RedirectResponse { $theme = ToolboxHelper::getValidatedEnum( - $request->theme ?: Cache::get('theme', BootstrapThemeEnum::light->value()), + $request->validated('theme') ?: Cache::get('theme', BootstrapThemeEnum::light->value()), 'theme', '\App\Http\Controllers\BootstrapThemeEnum', ); diff --git a/app/Http/Requests/Bo/ClaimMessages/StoreMessageRequest.php b/app/Http/Requests/Bo/ClaimMessages/StoreMessageRequest.php new file mode 100644 index 0000000..48e9e62 --- /dev/null +++ b/app/Http/Requests/Bo/ClaimMessages/StoreMessageRequest.php @@ -0,0 +1,66 @@ +check(); + } + + /** + * Prepare the data for validation. + * + * @return void + */ + protected function prepareForValidation(): void + { + /** @var \App\Models\User $userModel */ + $userModel = auth('backend')->user(); + + $this->merge([ + 'user_id' => $userModel->getKey(), + 'type' => ClaimMessageType::human->value(), + ]); + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules(): array + { + return [ + 'claim_id' => 'required|numeric|exists:claims,id', + 'user_id' => 'required|numeric|exists:users,id', + 'content' => 'required|string|between:3,255', + 'type' => ['required', new Enum(ClaimMessageType::class)], + ]; + } + + /** + * Get custom attributes for validator errors. + * + * @return array|null> + */ + public function attributes(): array + { + return [ + 'claim_id' => trans('models.classes.claims'), + 'user_id' => trans('models.classes.users'), + 'content' => trans('validation.attributes.content'), + 'type' => trans('validation.custom.type'), + ]; + } +} diff --git a/app/Http/Requests/Bo/ClaimMessages/UpdateMessageRequest.php b/app/Http/Requests/Bo/ClaimMessages/UpdateMessageRequest.php new file mode 100644 index 0000000..9230745 --- /dev/null +++ b/app/Http/Requests/Bo/ClaimMessages/UpdateMessageRequest.php @@ -0,0 +1,44 @@ +check(); + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules(): array + { + return [ + 'claim_message_id' => 'required|numeric|exists:claim_messages,id', + 'content' => 'required|string|between:3,255', + ]; + } + + /** + * Get custom attributes for validator errors. + * + * @return array|null> + */ + public function attributes(): array + { + return [ + 'claim_message_id' => trans('models.classes.claim_messages'), + 'content' => trans('validation.attributes.content'), + ]; + } +} diff --git a/app/Http/Requests/Bo/Claims/SendClaimAnswerRequest.php b/app/Http/Requests/Bo/Claims/SendClaimAnswerRequest.php new file mode 100644 index 0000000..590d7c4 --- /dev/null +++ b/app/Http/Requests/Bo/Claims/SendClaimAnswerRequest.php @@ -0,0 +1,44 @@ +check(); + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules(): array + { + return [ + 'claim_id' => 'required|numeric|exists:claims,id', + 'content' => 'required|string|between:3,500', + ]; + } + + /** + * Get custom attributes for validator errors. + * + * @return array|null> + */ + public function attributes(): array + { + return [ + 'claim_id' => trans('models.classes.claims'), + 'content' => trans('validation.attributes.content'), + ]; + } +} diff --git a/app/Http/Requests/Bo/Claims/UpdateClaimRequest.php b/app/Http/Requests/Bo/Claims/UpdateClaimRequest.php new file mode 100644 index 0000000..4214450 --- /dev/null +++ b/app/Http/Requests/Bo/Claims/UpdateClaimRequest.php @@ -0,0 +1,54 @@ +check(); + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules(): array + { + return [ + 'brand_id' => 'required|numeric|exists:brands,id', + 'subject_id' => 'required|numeric|exists:claim_subjects,id', + 'type' => ['required', new Enum(ClaimType::class)], + 'status' => ['required', new Enum(ClaimStatus::class)], + 'response_type' => ['present', 'nullable', new Enum(ClaimResponseType::class)], + ]; + } + + /** + * Get custom attributes for validator errors. + * + * @return array|null> + */ + public function attributes(): array + { + return [ + 'brand_id' => trans('models.classes.brands'), + 'subject_id' => trans('models.classes.claim_subjects'), + 'type' => trans('validation.custom.type'), + 'status' => trans('validation.custom.status'), + 'response_type' => trans('validation.custom.response_type'), + ]; + } +} diff --git a/app/Http/Requests/Bo/PaginateModelsRequest.php b/app/Http/Requests/Bo/PaginateModelsRequest.php new file mode 100644 index 0000000..ace8877 --- /dev/null +++ b/app/Http/Requests/Bo/PaginateModelsRequest.php @@ -0,0 +1,52 @@ +|string> + */ + public function rules(): array + { + return [ + 'targetModel' => [ + 'required', + 'string', + 'starts_with:App\\Models\\', + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed + function ($attribute, $value, $fail) { + if (!class_exists($value)) { + $fail("Le modèle spécifié n'existe pas."); + return; + } + if (!is_subclass_of($value, \Illuminate\Database\Eloquent\Model::class)) { + $fail("Le modèle spécifié n'est pas un modèle Eloquent."); + } + }, + ], + 'page' => 'required|integer|min:1', + 'paginate' => 'required|integer|min:1', + 'fieldName' => 'required|string|alpha_dash|max:255', + ]; + } + + /** + * Get custom attributes for validator errors. + * + * @return array|null> + */ + public function attributes(): array + { + return [ + 'targetModel' => trans('validation.custom.targetModel'), + 'page' => trans('validation.custom.page'), + 'paginate' => trans('validation.custom.paginate'), + 'fieldName' => trans('validation.custom.fieldName'), + ]; + } +} diff --git a/app/Http/Requests/Bo/Questions/StoreQuestionRequest.php b/app/Http/Requests/Bo/Questions/StoreQuestionRequest.php index fa6e9c0..1bc827f 100644 --- a/app/Http/Requests/Bo/Questions/StoreQuestionRequest.php +++ b/app/Http/Requests/Bo/Questions/StoreQuestionRequest.php @@ -18,18 +18,6 @@ class StoreQuestionRequest extends FormRequest return auth('backend')->check(); } - /** - * Prepare the data for validation. - * - * @return void - */ - protected function prepareForValidation(): void - { - $this->merge([ - 'brand_id' => collect($this->brand)->pluck('id')->first() - ]); - } - /** * Get the validation rules that apply to the request. * diff --git a/app/Http/Requests/Bo/Services/StoreServiceRequest.php b/app/Http/Requests/Bo/Services/StoreServiceRequest.php index d436929..e87f37f 100644 --- a/app/Http/Requests/Bo/Services/StoreServiceRequest.php +++ b/app/Http/Requests/Bo/Services/StoreServiceRequest.php @@ -16,18 +16,6 @@ class StoreServiceRequest extends FormRequest return auth('backend')->check(); } - /** - * Prepare the data for validation. - * - * @return void - */ - protected function prepareForValidation(): void - { - $this->merge([ - 'brand_id' => collect($this->brand)->pluck('id')->first() - ]); - } - /** * Get the validation rules that apply to the request. * diff --git a/app/Http/Requests/Bo/ThemeRequest.php b/app/Http/Requests/Bo/ThemeRequest.php new file mode 100644 index 0000000..8b16052 --- /dev/null +++ b/app/Http/Requests/Bo/ThemeRequest.php @@ -0,0 +1,34 @@ +|string> + */ + public function rules(): array + { + return [ + 'theme' => ['required', new Enum(BootstrapThemeEnum::class)], + ]; + } + + /** + * Get custom attributes for validator errors. + * + * @return array|null> + */ + public function attributes(): array + { + return [ + 'theme' => trans('validation.custom.theme'), + ]; + } +} diff --git a/app/Http/Requests/Bo/Users/UpdateUserRequest.php b/app/Http/Requests/Bo/Users/UpdateUserRequest.php index 5dede0b..1b4dc56 100644 --- a/app/Http/Requests/Bo/Users/UpdateUserRequest.php +++ b/app/Http/Requests/Bo/Users/UpdateUserRequest.php @@ -11,11 +11,11 @@ class UpdateUserRequest extends StoreUserRequest * * @return void */ - protected function prepareForValidation() + protected function prepareForValidation(): void { $this->merge([ - 'published' => $this->published ? true : false, - 'password' => $this->password ? $this->password : $this->route('user')->password, + 'published' => $this->published ? true : false, + 'password' => $this->password ? $this->password : $this->route('user')->password, 'password_confirmation' => $this->password_confirmation ? $this->password_confirmation : $this->route('user')->password @@ -30,7 +30,7 @@ class UpdateUserRequest extends StoreUserRequest public function rules(): array { return array_merge(parent::rules(), [ - 'email' => [ + 'email' => [ 'required', 'email:rfc,strict,dns,spoof,filter', 'unique:users,email,' . $this->route('user')->id . ',id', diff --git a/app/Listeners/AddClaimMessageSystem.php b/app/Listeners/AddClaimMessageSystem.php new file mode 100644 index 0000000..086568f --- /dev/null +++ b/app/Listeners/AddClaimMessageSystem.php @@ -0,0 +1,123 @@ +createClaimMessage($event); + + // Assign content based on whether there is a custom message or default handling. + $message->content = $event->content ? $event->content : $this->generateMessageContent($event); + + $message->saveOrFail(); + } + + /** + * Create a new ClaimMessage instance. + * + * @param \App\Events\ClaimModelChanged $event + * @return \App\Models\ClaimMessage + */ + private function createClaimMessage(ClaimModelChanged $event): ClaimMessage + { + return new ClaimMessage([ + 'claim_id' => $event->claim->getKey(), + 'user_id' => null, + 'type' => ClaimMessageType::system, + ]); + } + + /** + * Generate the message content based on the event data. + * + * @param \App\Events\ClaimModelChanged $event + * @return string + */ + private function generateMessageContent(ClaimModelChanged $event): string + { + // Check for Enum type and generate content accordingly. + $castType = $event->claim->getCasts()[$event->field] ?? null; + if ($castType && enum_exists($castType) && str_starts_with($castType, "App\\Enums\\Claims\\")) { + return $this->generateEnumMessageContent($event); + } + + // Default field message content. + return $this->generateDefaultFieldMessageContent($event); + } + + /** + * Generate message content for Enum type fields. + * + * @param \App\Events\ClaimModelChanged $event + * @return string + */ + private function generateEnumMessageContent(ClaimModelChanged $event): string + { + $enumLabel = $event->claim->{$event->field}->label(); + $enumColor = $event->claim->{$event->field}->color(); + $baseMessage = trans(':field est passé à', ['field' => $event->label]); + + // If the user is available, include user details in the message. + if ($event->user) { + return sprintf( + "%s %s %s %s", + $event->user->first_name, + $event->user->last_name, + trans('a modifié le :field en', ['field' => $event->label]), + $enumColor, + $enumLabel, + ); + } + + // User is not available, return a simple enum change message. + return sprintf( + "%s : %s", + $baseMessage, + $enumColor, + $enumLabel, + ); + } + + /** + * Generate message content for default field types. + * + * @param \App\Events\ClaimModelChanged $event + * @return string + */ + private function generateDefaultFieldMessageContent(ClaimModelChanged $event): string + { + $field = $event->claim->{$event->field}; + $baseMessage = trans(':field est passé à', ['field' => $event->label]); + $fieldLabel = $field->label ?? $field->name; + + // If the user is available, include user details in the message. + if ($event->user) { + return sprintf( + "%s %s %s %s", + $event->user->first_name, + $event->user->last_name, + trans('a modifié le :field en', ['field' => $event->label]), + $fieldLabel, + ); + } + + // User is not available, return a simple field change message. + return sprintf( + "%s : %s", + $baseMessage, + $fieldLabel, + ); + } +} diff --git a/app/Mail/ClaimAnswerMail.php b/app/Mail/ClaimAnswerMail.php new file mode 100644 index 0000000..69a2d27 --- /dev/null +++ b/app/Mail/ClaimAnswerMail.php @@ -0,0 +1,70 @@ +claimModel = $claimModel; + $this->answer = $answer; + } + + /** + * Build the message. + * + * @return $this + */ + public function build() + { + return $this + ->from("no-reply@{$this->claimModel->brand->domain}") + ->subject(sprintf( + 'Réponse réclamation %s - %s', + $this->claimModel->reference, + $this->claimModel->brand->name + )) + ->markdown('mail.send-claim-answer') + ->text('mail.send-claim-answer-plain') + ->with([ + 'customHeader' => view('vendor.mail.html.header-claim-answer', [ + 'brandModel' => $this->claimModel->brand, + ])->render(), + 'customFooter' => view('vendor.mail.html.footer-claim-answer', [ + 'brandModel' => $this->claimModel->brand, + ])->render(), + 'claimModel' => $this->claimModel, + 'answer' => $this->answer, + ]); + } +} diff --git a/app/Models/Claim.php b/app/Models/Claim.php index c7fc7bf..219fd70 100644 --- a/app/Models/Claim.php +++ b/app/Models/Claim.php @@ -2,29 +2,33 @@ namespace App\Models; +use App\Enums\Claims\ClaimResponseType; use App\Enums\Claims\ClaimStatus; use App\Enums\Claims\ClaimType; +use App\Events\ClaimModelChanged; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Support\Str; /** - * @property integer $id Claim id. - * @property string $reference Claim reference. - * @property string $first_name Claimant\'s first name. - * @property string $last_name Claimant\'s last name. - * @property string $email Claimant\'s email. - * @property string|null $address Claimant\'s address. - * @property string|null $city Claimant\'s city. - * @property string|null $postcode Claimant\'s postcode. - * @property string|null $file Claimant\'s file. - * @property string $message Claimant\'s message. - * @property \App\Enums\Claims\ClaimType $type Claim type (ClaimType enum). - * @property \App\Enums\Claims\ClaimStatus $status Claim status (ClaimStatus enum). - * @property \App\Models\Brand $brand_id Claim associated Brand. - * @property \App\Models\ClaimSubject $subject_id Claim associated Subject. - * @property \App\Models\Customer|null $customer_id Claim associated Customer. - * @property-read \Illuminate\Support\Carbon $created_at Claim created date. - * @property-read \Illuminate\Support\Carbon $updated_at Claim updated date. + * @property integer $id Claim id. + * @property string $reference Claim reference. + * @property string $first_name Claimant\'s first name. + * @property string $last_name Claimant\'s last name. + * @property string $email Claimant\'s email. + * @property string|null $address Claimant\'s address. + * @property string|null $city Claimant\'s city. + * @property string|null $postcode Claimant\'s postcode. + * @property string|null $file Claimant\'s file. + * @property string $message Claimant\'s message. + * @property \App\Enums\Claims\ClaimResponseType $response_type Claim type (ClaimResponseType enum). + * @property \App\Enums\Claims\ClaimStatus $status Claim status (ClaimStatus enum). + * @property \App\Enums\Claims\ClaimType $type Claim type (ClaimType enum). + * @property \App\Models\Brand $brand_id Claim associated Brand. + * @property \App\Models\ClaimSubject $subject_id Claim associated Subject. + * @property \App\Models\Customer|null $customer_id Claim associated Customer. + * @property-read \Illuminate\Support\Carbon $created_at Claim created date. + * @property-read \Illuminate\Support\Carbon $updated_at Claim updated date. */ class Claim extends Model { @@ -45,8 +49,9 @@ class Claim extends Model 'postcode', 'file', 'message', - 'type', + 'response_type', 'status', + 'type', 'brand_id', 'subject_id', 'customer_id', @@ -58,8 +63,9 @@ class Claim extends Model * @var array */ protected $casts = [ - 'type' => ClaimType::class, - 'status' => ClaimStatus::class, + 'response_type' => ClaimResponseType::class, + 'status' => ClaimStatus::class, + 'type' => ClaimType::class, ]; /** @@ -73,6 +79,56 @@ class Claim extends Model $model->reference = self::encodeIntegerToBase36($model->getKey()); $model->saveOrFail(); }); + static::updated(function (self $model) { + $user = auth()->user(); + if (!$user instanceof \App\Models\User) { + $user = null; + } + + if (isset($model->getChanges()['brand_id'])) { + event(new ClaimModelChanged( + $model->load('brand'), + 'brand', + Str::singular(trans('models.classes.brands')), + $user, + )); + } + if (isset($model->getChanges()['subject_id'])) { + event(new ClaimModelChanged( + $model->load('claimSubject'), + 'claimSubject', + trans('models.classes.claim_subjects'), + $user, + )); + } + if (isset($model->getChanges()['status'])) { + event(new ClaimModelChanged( + $model, + 'status', + trans('validation.custom.status'), + $user, + )); + } + if (isset($model->getChanges()['type'])) { + event(new ClaimModelChanged( + $model, + 'type', + trans('validation.custom.type'), + $user, + )); + } + if ( + isset($model->getChanges()['response_type']) + && !$model->response_type->equals(ClaimResponseType::manual) + ) { + event(new ClaimModelChanged( + $model, + 'response_type', + trans('validation.custom.response_type'), + $user, + )); + } + }); } // * RELATIONS @@ -94,7 +150,7 @@ class Claim extends Model */ public function claimSubject(): \Illuminate\Database\Eloquent\Relations\BelongsTo { - return $this->belongsTo(ClaimSubject::class); + return $this->belongsTo(ClaimSubject::class, 'subject_id'); } /** @@ -140,4 +196,17 @@ class Claim extends Model { return base_convert(strtolower($str), 36, 10); } + + /** + * Get formated address. + * + * @return string + */ + public function getFormatedAddress(): string + { + return implode(', ', array_filter([ + $this->address, + trim(implode(' ', array_filter([$this->postcode, $this->city]))) + ])); + } } diff --git a/app/Models/ClaimMessage.php b/app/Models/ClaimMessage.php index e28435d..4fa2854 100644 --- a/app/Models/ClaimMessage.php +++ b/app/Models/ClaimMessage.php @@ -59,4 +59,22 @@ class ClaimMessage extends Model { return $this->belongsTo(User::class); } + + + // * METHODS + + /** + * Get all messages from a specific claim. + * + * @param integer $claimModelKey + * @return \Illuminate\Database\Eloquent\Collection + */ + public static function getAllClaimMessages(int $claimModelKey): \Illuminate\Database\Eloquent\Collection + { + return self::query() + ->with('user') + ->whereHas('claim', fn($q) => $q->whereKey($claimModelKey)) + ->orderby('created_at', 'ASC') + ->get(); + } } diff --git a/app/Policies/ActivityLogPolicy.php b/app/Policies/ActivityLogPolicy.php new file mode 100644 index 0000000..fb24e32 --- /dev/null +++ b/app/Policies/ActivityLogPolicy.php @@ -0,0 +1,32 @@ +login($service->brand)); } + + /** + * Export Customers. + * + * @param \App\Models\User $authUser + * @return boolean + */ + public function export(User $authUser): bool + { + return UserStaticRules::atLeastRole($authUser, RoleEnum::admin); + } } diff --git a/app/Policies/QuestionPolicy.php b/app/Policies/QuestionPolicy.php index 9a55808..3bb2627 100644 --- a/app/Policies/QuestionPolicy.php +++ b/app/Policies/QuestionPolicy.php @@ -2,60 +2,67 @@ namespace App\Policies; +use App\Enums\Users\RoleEnum; use App\Models\Question; use App\Models\Service; -use App\Policies\Rules\UserStaticRules as USR; +use App\Models\User; +use App\Policies\Rules\UserStaticRules; class QuestionPolicy { /** * View a Question. * + * @param \App\Models\User $authUser * @return boolean */ - public function view(): bool + public function view(User $authUser): bool { - return USR::everyOne(); + return UserStaticRules::atLeastRole($authUser, RoleEnum::admin); } /** * ViewAny a Question. * + * @param \App\Models\User $authUser * @return boolean */ - public function viewAny(): bool + public function viewAny(User $authUser): bool { - return USR::everyOne(); + return UserStaticRules::atLeastRole($authUser, RoleEnum::admin); } /** * Create a Question. * + * @param \App\Models\User $authUser * @return boolean */ - public function create(): bool + public function create(User $authUser): bool { - return USR::everyOne(); + return UserStaticRules::atLeastRole($authUser, RoleEnum::admin); } /** * Update a Question. * + * @param \App\Models\User $authUser * @return boolean */ - public function update(): bool + public function update(User $authUser): bool { - return USR::everyOne(); + return UserStaticRules::atLeastRole($authUser, RoleEnum::admin); } /** * Delete a Question. * + * @param \App\Models\User $authUser * @return boolean */ - public function delete(): bool + public function delete(User $authUser): bool { - return USR::everyOne(); + return UserStaticRules::atLeastRole($authUser, RoleEnum::admin); } /** @@ -69,4 +76,15 @@ class QuestionPolicy { return $service->brand->id === $question->brand_id; } + + /** + * Export Customers. + * + * @param \App\Models\User $authUser + * @return boolean + */ + public function export(User $authUser): bool + { + return UserStaticRules::atLeastRole($authUser, RoleEnum::admin); + } } diff --git a/app/Policies/ServicePolicy.php b/app/Policies/ServicePolicy.php index 77d3c36..bec80ae 100644 --- a/app/Policies/ServicePolicy.php +++ b/app/Policies/ServicePolicy.php @@ -2,48 +2,54 @@ namespace App\Policies; -use App\Policies\Rules\UserStaticRules as USR; +use App\Enums\Users\RoleEnum; +use App\Models\User; +use App\Policies\Rules\UserStaticRules; class ServicePolicy { /** * View an Answer. * + * @param \App\Models\User $authUser * @return boolean */ - public function view(): bool + public function view(User $authUser): bool { - return USR::everyOne(); + return UserStaticRules::atLeastRole($authUser, RoleEnum::admin); } /** * ViewAny an Service. * + * @param \App\Models\User $authUser * @return boolean */ - public function viewAny(): bool + public function viewAny(User $authUser): bool { - return USR::everyOne(); + return UserStaticRules::atLeastRole($authUser, RoleEnum::admin); } /** * Create an Service. * + * @param \App\Models\User $authUser * @return boolean */ - public function create(): bool + public function create(User $authUser): bool { - return USR::everyOne(); + return UserStaticRules::atLeastRole($authUser, RoleEnum::admin); } /** * Update an Service. * + * @param \App\Models\User $authUser * @return boolean */ - public function update(): bool + public function update(User $authUser): bool { - return USR::everyOne(); + return UserStaticRules::atLeastRole($authUser, RoleEnum::admin); } /** @@ -53,6 +59,6 @@ class ServicePolicy */ public function delete(): bool { - return USR::noOne(); + return UserStaticRules::noOne(); } } diff --git a/app/Policies/SingleOptinPolicy.php b/app/Policies/SingleOptinPolicy.php index a9cd08d..ca7ab28 100644 --- a/app/Policies/SingleOptinPolicy.php +++ b/app/Policies/SingleOptinPolicy.php @@ -2,7 +2,9 @@ namespace App\Policies; -use App\Policies\Rules\UserStaticRules as USR; +use App\Enums\Users\RoleEnum; +use App\Models\User; +use App\Policies\Rules\UserStaticRules; class SingleOptinPolicy { @@ -13,17 +15,18 @@ class SingleOptinPolicy */ public function view(): bool { - return USR::noOne(); + return UserStaticRules::noOne(); } /** * ViewAny an Answer. * + * @param \App\Models\User $authUser * @return boolean */ - public function viewAny(): bool + public function viewAny(User $authUser): bool { - return USR::everyOne(); + return UserStaticRules::atLeastRole($authUser, RoleEnum::admin); } /** @@ -33,7 +36,7 @@ class SingleOptinPolicy */ public function create(): bool { - return USR::noOne(); + return UserStaticRules::noOne(); } /** @@ -43,16 +46,17 @@ class SingleOptinPolicy */ public function update(): bool { - return USR::noOne(); + return UserStaticRules::noOne(); } /** * Delete an Answer. * + * @param \App\Models\User $authUser * @return boolean */ - public function delete(): bool + public function delete(User $authUser): bool { - return USR::everyOne(); + return UserStaticRules::atLeastRole($authUser, RoleEnum::admin); } } diff --git a/app/Policies/StatisticPolicy.php b/app/Policies/StatisticPolicy.php new file mode 100644 index 0000000..a5f69ab --- /dev/null +++ b/app/Policies/StatisticPolicy.php @@ -0,0 +1,43 @@ +role); } @@ -40,7 +40,7 @@ class UserPolicy */ public function create(User $authUser): bool { - return UserStaticRules::atLeastRole($authUser, RoleEnum::admin); + return UserStaticRules::atLeastRole($authUser, RoleEnum::conceptor); } /** @@ -53,7 +53,7 @@ class UserPolicy public function update(User $authUser, User $user): bool { return $authUser->getRouteKey() === $user->getRouteKey() or - (UserStaticRules::atLeastRole($authUser, RoleEnum::admin) and + (UserStaticRules::atLeastRole($authUser, RoleEnum::conceptor) and UserStaticRules::atLeastRole($authUser, $user->role)); } @@ -67,7 +67,7 @@ class UserPolicy public function delete(User $authUser, User $user): bool { return $authUser->getRouteKey() !== $user->getRouteKey() and - UserStaticRules::atLeastRole($authUser, RoleEnum::admin) and + UserStaticRules::atLeastRole($authUser, RoleEnum::conceptor) and UserStaticRules::atLeastRole($authUser, $user->role); } @@ -81,7 +81,7 @@ class UserPolicy public function restore(User $authUser, User $user): bool { return $authUser->getRouteKey() !== $user->getRouteKey() and - UserStaticRules::atLeastRole($authUser, RoleEnum::admin) and + UserStaticRules::atLeastRole($authUser, RoleEnum::conceptor) and UserStaticRules::atLeastRole($authUser, $user->role); } @@ -95,7 +95,7 @@ class UserPolicy public function forceDelete(User $authUser, User $user): bool { return $authUser->getRouteKey() !== $user->getRouteKey() and - UserStaticRules::atLeastRole($authUser, RoleEnum::admin) and + UserStaticRules::atLeastRole($authUser, RoleEnum::conceptor) and UserStaticRules::atLeastRole($authUser, $user->role); } @@ -109,7 +109,7 @@ class UserPolicy public function duplicate(User $authUser, User $user): bool { return $authUser->getRouteKey() !== $user->getRouteKey() and - UserStaticRules::atLeastRole($authUser, RoleEnum::admin) and + UserStaticRules::atLeastRole($authUser, RoleEnum::conceptor) and UserStaticRules::atLeastRole($authUser, $user->role); } @@ -123,7 +123,7 @@ class UserPolicy public function changePublished(User $authUser, User $user): bool { return $authUser->getRouteKey() !== $user->getRouteKey() and - UserStaticRules::atLeastRole($authUser, RoleEnum::admin) and + UserStaticRules::atLeastRole($authUser, RoleEnum::conceptor) and UserStaticRules::atLeastRole($authUser, $user->role); } } diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index b50eaea..1baf8c4 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -6,6 +6,7 @@ use App\Enums\Users\RoleEnum; use App\Lib\Helper; use App\Models\Service; use App\Models\User; +use App\Policies\StatisticPolicy; use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; use Illuminate\Http\Request; @@ -35,6 +36,10 @@ class AuthServiceProvider extends ServiceProvider return $user->role === RoleEnum::conceptor; }); + Gate::define('viewStatsByBrand', [StatisticPolicy::class, 'viewStatsByBrand']); + Gate::define('viewByQuestion', [StatisticPolicy::class, 'viewByQuestion']); + Gate::define('answersByDays', [StatisticPolicy::class, 'answersByDays']); + Auth::viaRequest('api-hmac', function (Request $request) { /** diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index 66ab757..c4133a5 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -2,6 +2,8 @@ namespace App\Providers; +use App\Events\ClaimModelChanged; +use App\Listeners\AddClaimMessageSystem; use App\Models\User; use Illuminate\Auth\Events\Registered; use Illuminate\Auth\Listeners\SendEmailVerificationNotification; @@ -20,9 +22,8 @@ class EventServiceProvider extends ServiceProvider * @var array> */ protected $listen = [ - Registered::class => [ - SendEmailVerificationNotification::class, - ], + Registered::class => [SendEmailVerificationNotification::class], + ClaimModelChanged::class => [AddClaimMessageSystem::class], ]; /** diff --git a/database/factories/ClaimFactory.php b/database/factories/ClaimFactory.php index e46c9e8..66944b0 100644 --- a/database/factories/ClaimFactory.php +++ b/database/factories/ClaimFactory.php @@ -2,6 +2,7 @@ namespace Database\Factories; +use App\Enums\Claims\ClaimResponseType; use App\Enums\Claims\ClaimStatus; use App\Enums\Claims\ClaimType; use App\Models\Brand; @@ -27,18 +28,19 @@ class ClaimFactory extends Factory public function definition(): array { return [ - 'first_name' => $this->faker->firstName(), - 'last_name' => $this->faker->lastName(), - 'email' => $this->faker->email(), - 'address' => $this->faker->optional()->address(), - 'city' => $this->faker->optional()->city(), - 'postcode' => $this->faker->optional()->postcode(), - 'message' => $this->faker->sentence(10), - 'type' => collect(ClaimType::toArray())->random()->value, - 'status' => collect(ClaimStatus::toArray())->random()->value, - 'brand_id' => $this->faker->randomElement(Brand::pluck('id')), - 'subject_id' => $this->faker->randomElement(ClaimSubject::pluck('id')), - 'customer_id' => $this->faker->boolean(50) ? $this->faker->randomElement(Customer::pluck('id')) : null, + 'first_name' => $this->faker->firstName(), + 'last_name' => $this->faker->lastName(), + 'email' => $this->faker->email(), + 'address' => $this->faker->optional()->address(), + 'city' => $this->faker->optional()->city(), + 'postcode' => $this->faker->optional()->postcode(), + 'message' => $this->faker->sentence(10), + 'response_type' => ClaimResponseType::none, + 'type' => collect(ClaimType::toArray())->random()->value, + 'status' => collect(ClaimStatus::toArray())->random()->value, + 'brand_id' => $this->faker->randomElement(Brand::pluck('id')), + 'subject_id' => $this->faker->randomElement(ClaimSubject::pluck('id')), + 'customer_id' => $this->faker->boolean(50) ? $this->faker->randomElement(Customer::pluck('id')) : null, ]; } } diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index d6ebccc..814b1f5 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -20,24 +20,11 @@ class UserFactory extends Factory 'first_name' => $this->faker->firstname(), 'last_name' => $this->faker->lastname(), 'email' => $this->faker->unique()->safeEmail(), - 'email_verified_at' => now(), - 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', 'remember_token' => Str::random(10), 'role' => \collect(RoleEnum::toArray())->random()->value, 'published' => $published, 'published_at' => ($published) ? now() : null, + 'last_connection' => ($published) ? now() : null, ]; } - - /** - * Indicate that the model's email address should be unverified. - * - * @return static - */ - public function unverified(): static - { - return $this->state(fn() => [ - 'email_verified_at' => null, - ]); - } } diff --git a/database/migrations/2025_07_24_113251_create_claims_table.php b/database/migrations/2025_07_24_113251_create_claims_table.php index 21193d8..969e73f 100644 --- a/database/migrations/2025_07_24_113251_create_claims_table.php +++ b/database/migrations/2025_07_24_113251_create_claims_table.php @@ -1,5 +1,6 @@ string('postcode')->nullable()->comment('Claimant\'s postcode.'); $table->string('file')->nullable()->comment('Claimant\'s file.'); $table->text('message')->comment('Claimant\'s message.'); - $table->unsignedTinyInteger('type')->default(ClaimType::classic) - ->comment('Claim type (ClaimType enum).'); + $table->unsignedTinyInteger('response_type')->default(ClaimResponseType::none) + ->comment('Claim response type (ClaimResponseType enum).'); $table->unsignedTinyInteger('status')->default(ClaimStatus::untreated) ->comment('Claim status (ClaimStatus enum).'); + $table->unsignedTinyInteger('type')->default(ClaimType::classic) + ->comment('Claim type (ClaimType enum).'); $table->foreignId('brand_id')->comment('Claim associated Brand.')->constrained('brands') ->onUpdate('cascade')->onDelete('cascade'); $table->foreignId('subject_id')->comment('Claim associated Subject.')->constrained('claim_subjects') diff --git a/database/migrations/2025_07_25_112127_alter_users_for_saml.php b/database/migrations/2025_07_25_112127_alter_users_for_saml.php index b3daaa9..57b04f3 100644 --- a/database/migrations/2025_07_25_112127_alter_users_for_saml.php +++ b/database/migrations/2025_07_25_112127_alter_users_for_saml.php @@ -16,7 +16,7 @@ return new class extends Migration Schema::table('users', function (Blueprint $table) { $table->dropColumn('email_verified_at'); $table->dropColumn('password'); - $table->date('last_connection')->nullable()->after('published_at'); + $table->timestamp('last_connection')->nullable()->after('published_at'); }); } diff --git a/package-lock.json b/package-lock.json index 06ac1a9..8ba17d9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "@types/bootstrap": "^5.2.7", "@types/node": "^20.8.2", "@types/toastify-js": "^1.12.1", + "@types/vue-select": "^3.16.5", "@vitejs/plugin-legacy": "latest", "@vitejs/plugin-vue": "latest", "@vue/compiler-sfc": "latest", @@ -42,6 +43,7 @@ "vite-plugin-eslint": "latest", "vite-plugin-stylelint": "latest", "vue": "latest", + "vue-select": "^4.0.0-beta.6", "vue-tsc": "1.6.0" } }, @@ -399,19 +401,21 @@ } }, "node_modules/@babel/helper-string-parser": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.22.5.tgz", - "integrity": "sha512-mM4COjgZox8U+JcXQwPijIZLElkgEpO5rsERVDJTc2qfCDfERyob6k5WegS14SX18IIjv+XD+GrqNumY5JRCDw==", + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz", + "integrity": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==", "dev": true, + "license": "MIT", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.22.20", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz", - "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==", + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.27.1.tgz", + "integrity": "sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow==", "dev": true, + "license": "MIT", "engines": { "node": ">=6.9.0" } @@ -468,10 +472,14 @@ } }, "node_modules/@babel/parser": { - "version": "7.23.0", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.0.tgz", - "integrity": "sha512-vvPKKdMemU85V9WE/l5wZEmImpCtLqbnTvqDS2U1fJ96KrxoW7KrXhNsNCblQlg8Ck4b85yxdTyelsMUgFUXiw==", + "version": "7.28.0", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.28.0.tgz", + "integrity": "sha512-jVZGvOxOuNSsuQuLRTh13nU0AogFlw32w/MT+LV6D3sP5WdbW61E77RnkbaO2dUvmPAYrBDJXGn5gGS6tH4j8g==", "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.28.0" + }, "bin": { "parser": "bin/babel-parser.js" }, @@ -1698,14 +1706,14 @@ } }, "node_modules/@babel/types": { - "version": "7.23.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.0.tgz", - "integrity": "sha512-0oIyUfKoI3mSqMvsxBdclDwxXKXAUA8v/apZbc+iSyARYou1o8ZGDxbUYyLFoW2arqS2jDGqJuZvv1d/io1axg==", + "version": "7.28.2", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.28.2.tgz", + "integrity": "sha512-ruv7Ae4J5dUYULmeXw1gmb7rYRz57OWCPM57pHojnLq/3Z1CK2lNSLTCVjxVk1F/TZHwOZZrOWi0ur95BbLxNQ==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/helper-string-parser": "^7.22.5", - "@babel/helper-validator-identifier": "^7.22.20", - "to-fast-properties": "^2.0.0" + "@babel/helper-string-parser": "^7.27.1", + "@babel/helper-validator-identifier": "^7.27.1" }, "engines": { "node": ">=6.9.0" @@ -2560,6 +2568,59 @@ "integrity": "sha512-9CTM+LKFmS0+Ii+RH55XPKcmNxCjLticj8kxeCxa7PnSVCZPQurb9XtKQtoMl/fv7WaqUpRezDcFuY8n92CtUg==", "dev": true }, + "node_modules/@types/vue-select": { + "version": "3.16.8", + "resolved": "https://registry.npmjs.org/@types/vue-select/-/vue-select-3.16.8.tgz", + "integrity": "sha512-ZBovlBrWf/wnPqCmMw24ryIC7ghQLfIBmkl1qssqBGONdx7yOmi/GLwtPxll/6UwXWGNWMeokleOgVAZPis+Ag==", + "dev": true, + "license": "MIT", + "dependencies": { + "vue": "^2.0.0" + } + }, + "node_modules/@types/vue-select/node_modules/@vue/compiler-sfc": { + "version": "2.7.16", + "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-2.7.16.tgz", + "integrity": "sha512-KWhJ9k5nXuNtygPU7+t1rX6baZeqOYLEforUPjgNDBnLicfHCoi48H87Q8XyLZOrNNsmhuwKqtpDQWjEFe6Ekg==", + "dev": true, + "dependencies": { + "@babel/parser": "^7.23.5", + "postcss": "^8.4.14", + "source-map": "^0.6.1" + }, + "optionalDependencies": { + "prettier": "^1.18.2 || ^2.0.0" + } + }, + "node_modules/@types/vue-select/node_modules/prettier": { + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", + "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", + "dev": true, + "license": "MIT", + "optional": true, + "bin": { + "prettier": "bin-prettier.js" + }, + "engines": { + "node": ">=10.13.0" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/@types/vue-select/node_modules/vue": { + "version": "2.7.16", + "resolved": "https://registry.npmjs.org/vue/-/vue-2.7.16.tgz", + "integrity": "sha512-4gCtFXaAA3zYZdTp5s4Hl2sozuySsgz4jy1EnpBHNfpMa9dK1ZCG7viqBPCwXtmgc8nHqUsAu3G4gtmXkkY3Sw==", + "deprecated": "Vue 2 has reached EOL and is no longer actively maintained. See https://v2.vuejs.org/eol/ for more details.", + "dev": true, + "license": "MIT", + "dependencies": { + "@vue/compiler-sfc": "2.7.16", + "csstype": "^3.1.0" + } + }, "node_modules/@typescript-eslint/eslint-plugin": { "version": "6.7.4", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.7.4.tgz", @@ -3312,9 +3373,9 @@ "dev": true }, "node_modules/bootstrap": { - "version": "5.3.2", - "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.3.2.tgz", - "integrity": "sha512-D32nmNWiQHo94BKHLmOrdjlL05q1c8oxbtBphQFb9Z5to6eGRDCm0QgeaZ4zFBHzfg2++rqa2JkqCcxDy0sH0g==", + "version": "5.3.7", + "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.3.7.tgz", + "integrity": "sha512-7KgiD8UHjfcPBHEpDNg+zGz8L3LqR3GVwqZiBRFX04a1BCArZOz1r2kjly2HQ0WokqTO0v1nF+QAt8dsW4lKlw==", "dev": true, "funding": [ { @@ -3326,6 +3387,7 @@ "url": "https://opencollective.com/bootstrap" } ], + "license": "MIT", "peerDependencies": { "@popperjs/core": "^2.11.8" } @@ -6780,15 +6842,6 @@ "integrity": "sha512-AD5ih2NlSssTCwsMznbvwMZpJ1cbhkGd2uueNxzv2jDlEeZdU04JQfRnggJQ8DrcVBGjAsCKwFBbDlVNtEMlzw==", "dev": true }, - "node_modules/to-fast-properties": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", - "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==", - "dev": true, - "engines": { - "node": ">=4" - } - }, "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", @@ -7468,6 +7521,16 @@ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "dev": true }, + "node_modules/vue-select": { + "version": "4.0.0-beta.6", + "resolved": "https://registry.npmjs.org/vue-select/-/vue-select-4.0.0-beta.6.tgz", + "integrity": "sha512-K+zrNBSpwMPhAxYLTCl56gaMrWZGgayoWCLqe5rWwkB8aUbAUh7u6sXjIR7v4ckp2WKC7zEEUY27g6h1MRsIHw==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "vue": "3.x" + } + }, "node_modules/vue-template-compiler": { "version": "2.7.14", "resolved": "https://registry.npmjs.org/vue-template-compiler/-/vue-template-compiler-2.7.14.tgz", diff --git a/package.json b/package.json index 67b4e5b..047696b 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "@types/bootstrap": "^5.2.7", "@types/node": "^20.8.2", "@types/toastify-js": "^1.12.1", + "@types/vue-select": "^3.16.5", "@vitejs/plugin-legacy": "latest", "@vitejs/plugin-vue": "latest", "@vue/compiler-sfc": "latest", @@ -49,6 +50,7 @@ "vite-plugin-eslint": "latest", "vite-plugin-stylelint": "latest", "vue": "latest", + "vue-select": "^4.0.0-beta.6", "vue-tsc": "1.6.0" } } diff --git a/resources/assets/images/logo_ldc.jpg b/resources/assets/images/logo_ldc.jpg new file mode 100644 index 0000000000000000000000000000000000000000..7132c2e985ff0ea4539ca41449715f7af0a2205e GIT binary patch literal 8795 zcmbW61yozhxA0FAlHl$T2(H21rC71zPLbg5QYuIVDNrbGMT!@SQwoLRRw%A5Ucm~b zIE63tzIE^Ye`~$>)_Qv-li%61_nDc!=ggT|xthIN0d!P?T^s>GTN~g8000|+fM@|I zhCrCF5Qy$?mI84CkU#qC@>)otRRF+2{P!=pG8roQ} zKlX3{1_A+?&mSGzA06?Z@?XW(D!!?PvhwX)`nswbS}ND(0KU4Gi>DVDW9#AR@2jt- zgfulXN5V${Fn|NV06_q-wfFPZHc&OZzLAECGSUxY^sk#@@M!wah=2){`Yj~#KkNS2 zD-wHeUw=$UZec8i(GGt07>>fQdyv2PwSEu7MLVd29rp9r+=~Czu4a)7}HMxQ1_D6Esb0GyKB_)vR z4ngh?{{E<2w)SqezG$Sfmxs5lX9xiNHRfwCfb=@HNKBB$1SQ49P(pl|@c%9UW98pg z|1(_Y_AiSAy+1hvQ4as3`^WbmomT+>NE~8fllYI$E&~9X9s&UM{69L@7XUyM1ptks z{~8bF^?Y&m_xG0K=MM@B;&XAZ=erK*-}1j2{B8N)!@t_&yKe9A*dcE?INAod`y;P| zYVYOl72u2X^R~5jK%)NtN&J6y{8zXB)el~M2S*2A2Tx2>#+X^=;^~A*wEij{W%&Q-_OCu%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MXn)M%lWUS#@nhuVX$3vBW@7HXZ)ot)blD`YPEjR^I*I5h pC!~DwcI5tMm=i=VW3^9TyWHxs3=vQev! literal 0 HcmV?d00001 diff --git a/resources/assets/images/logo_ldc.png b/resources/assets/images/logo_ldc.png deleted file mode 100644 index a775f6d0af06910b974128da192b80e52b5950eb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6686 zcmaJ`WmHscyQUPRyJLm{@s*BY7&?Y-L_|_x1{e^A7`mI07Ni8}ltxifKtvj(yOHh` z5DtFld%tsjocHXt_P(FzS=V*lx%Q8}F*;hxB!rBFSXfvjswyzOJNxH$CAfe0B$|Cn zaAz3MiiYSXC~LHbg$n{p4vw-!08||;Y!G?~3%HkaH$oB%3-=*X-waZaJpk-VM)q(I$2oRBhUa#gbmVBihaNF3p)S_mtubg))dfmQb5=uRlHpgPrSAC zt-S56pm25>X@I1s_?>_Q0&M~Cba?6LD()%8{x4neyY-)Aes;jWAZU9j_WusbP*Vq> zfO0_qz-R)Qj600hb>C@L%hh4KJ|1O&zS1;qFTg?R-<#YF_fg@geAzS!@)xxlT( z^_I0+0o*w(#V2bOrsb z07JN1xged;NR%VskD`So$_*{Wei!L~r{Li9A6ZA&f0ya5VEmpIPW*y=0)JBa8>p%I z|3e)d{)2W!>mmLp-v3kBRo}}A!LNsKMY*|H-8Ie{^v9KxxPlA90*!LfN1#?wCV^v{t`kvD}rueD)V^jX9tU3t^iJ3=_gJF33(GLNyLdj=v zG53fJLnd1pV=%z%aQX)~l*TxeF@p3V7x=1jujD|MqaBn4FR-!YUiiGN5q7m7fO;5C zB6>5^8mqiA$OeV?_WJ7ATh6!FB^I2L5kT#Fs;r1s7D|Z=Qy@cPw^&5<5?dr~WMiB*DDN6Nf?Srf~OW25D$J5XzKeHgW3=R#SnKC1-bOogCpZ`Ozm zB>lak4M|eylT`85pm*tW(IQ{VP*utbpuTBwdbiUm#`G7RxmCG>hSg$a$#`XON&~g9 z0%TwzZa8+Y2-eT1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JNrDQmFg%SeA7Q zl|J;z&-%N*NyBwTz=FGXMOnXAL7lTYYu8zl;jhP|;rx+B)cFyhsr`I+2j`BQ??oY6 z@7`o{7*ymQ}zz1E9&HdZ5xgw=H5pe zGFPwDvOxjR?t(Kpm-R564_7Yzp9aDjep?yXXvKMt;9%d5BKwditEn%}w2}%fg#E8- zwn(Qj4Vx*)6n;m~G6yPAGvQl5taQMqMzFnr0|7+9G)FLAYBjCx?GzetHD>Xslqy>? zKHPnH{>=athS{m&FLk7NwA59+uNBMk;5Dt00w;$NY9K0fsubw+O6O!_mb8dSsuAl- zDb7+iX7PcX2zqqEpL_e9DfP@$r6{_}cw}!ntmD<2Na-W`?XG<}tW#HOg#}~GP_S~N z@8=2}Rbx*2#unMr?xKSI`7Hs?LSR_%gG8O0fFn_uu&P7!Ng1Z<*Uxc}8= z%Iup0zeBq-qszPZ)5Y%4f}|gZn*WjO=zIYG;Sdu;s-Bu$@2jFQWVn9y zTbg)-rf+*aWe|9>Kl4IS@&qjpA&YrPr@{NG zb<-;61Gghx>>k+>H)aN+`HRc`nFzLf-1rMT#slBh [ - 'user' => 'user', - 'activity_log' => 'activity log|activity logs', - 'services' => 'Services', - 'brands' => 'Brands', - 'brand' => 'Brand', - 'customers' => 'Customers', - 'questions' => 'Questions', - 'answers' => 'Answers', - 'singleoptins' => 'Single Opt-ins' + 'user' => 'user', + 'activity_log' => 'activity log|activity logs', + 'services' => 'Services', + 'brands' => 'Brands', + 'customers' => 'Customers', + 'questions' => 'Questions', + 'answers' => 'Answers', + 'singleoptins' => 'Single Opt-ins', + 'claims' => 'Claims', + 'claim_subjects' => 'Subjects', + 'claim_mail_templates' => 'Templates', ], 'common' => [ - 'title' => 'Title', - 'name' => 'Name', - 'email' => 'Email', - 'content' => 'Content', + 'title' => 'Title', + 'name' => 'Name', + 'email' => 'Email', + 'content' => 'Content', 'visibility' => 'Visibility', - 'published' => 'Published', - 'group' => 'Group', - 'default' => 'Default', - 'optinDate' => 'Date opt-in', - 'question' => 'Question', - 'answer' => 'Answer', - 'type' => 'Type' + 'published' => 'Published', + 'group' => 'Group', + 'default' => 'Default', + 'optinDate' => 'Date opt-in', + 'question' => 'Question', + 'answer' => 'Answer', + 'type' => 'Type', ] ]; diff --git a/resources/lang/en/validation.php b/resources/lang/en/validation.php index b3de898..93b5672 100644 --- a/resources/lang/en/validation.php +++ b/resources/lang/en/validation.php @@ -222,11 +222,15 @@ return [ 'year' => 'year', ], 'custom' => [ - 'event' => 'event', - 'model' => 'target element', - 'order' => 'order', - 'publication' => 'publication', - 'activated' => 'activated', - 'target' => 'target', + 'event' => 'event', + 'model' => 'target element', + 'order' => 'order', + 'publication' => 'publication', + 'activated' => 'activated', + 'target' => 'target', + 'response_type' => 'response type', + 'reference' => 'reference', + 'type' => 'type', + 'status' => 'status', ], ]; diff --git a/resources/lang/fr/models.php b/resources/lang/fr/models.php index 4de8b2c..2ae3fd2 100644 --- a/resources/lang/fr/models.php +++ b/resources/lang/fr/models.php @@ -2,28 +2,30 @@ return [ 'classes' => [ - 'user' => 'utilisateur', - 'activity_log' => 'journal d\'activité|journaux d\'activité', - 'services' => 'Services', - 'brands' => 'Marques', - 'brand' => 'Marque', - 'questions' => 'Questions', - 'answers' => 'Réponses', - 'customers' => 'Clients', - 'singleoptins' => 'Opt-ins uniques' + 'user' => 'utilisateur', + 'activity_log' => 'journal d\'activité|journaux d\'activité', + 'services' => 'Services', + 'brands' => 'Marques', + 'questions' => 'Questions', + 'answers' => 'Réponses', + 'customers' => 'Clients', + 'singleoptins' => 'Opt-ins uniques', + 'claims' => 'Réclamations', + 'claim_subjects' => 'Sujets', + 'claim_mail_templates' => 'Modèles', ], 'common' => [ - 'title' => 'Titre', - 'name' => 'Nom', - 'email' => 'E-mail', - 'content' => 'Contenu', + 'title' => 'Titre', + 'name' => 'Nom', + 'email' => 'E-mail', + 'content' => 'Contenu', 'visibility' => 'Visibilitée', - 'published' => 'Publié', - 'group' => 'Groupe', - 'default' => 'Par défaut', - 'optinDate' => 'Date opt-in', - 'question' => 'Question', - 'type' => 'Type', - 'answer' => 'Réponse' + 'published' => 'Publié', + 'group' => 'Groupe', + 'default' => 'Par défaut', + 'optinDate' => 'Date opt-in', + 'question' => 'Question', + 'type' => 'Type', + 'answer' => 'Réponse', ] ]; diff --git a/resources/lang/fr/validation.php b/resources/lang/fr/validation.php index d66800e..e2c8940 100644 --- a/resources/lang/fr/validation.php +++ b/resources/lang/fr/validation.php @@ -222,11 +222,15 @@ return [ 'year' => 'année', ], 'custom' => [ - 'event' => 'évènement', - 'model' => 'élément ciblé', - 'order' => 'order', - 'publication' => 'publication', - 'activated' => 'activé', - 'target' => 'cible', + 'event' => 'évènement', + 'model' => 'élément ciblé', + 'order' => 'order', + 'publication' => 'publication', + 'activated' => 'activé', + 'target' => 'cible', + 'response_type' => 'type de réponse', + 'reference' => 'référence', + 'type' => 'type', + 'status' => 'status', ], ]; diff --git a/resources/sass/bo/base/_common.scss b/resources/sass/bo/base/_common.scss index 4eb609e..9783ac7 100644 --- a/resources/sass/bo/base/_common.scss +++ b/resources/sass/bo/base/_common.scss @@ -64,3 +64,11 @@ main { border-radius: 0 0 0.375rem !important; } } + +#sidebar-menu > .sticky-top { + top: 4rem !important; +} + +.claim-modal-content { + max-height: 20rem; +} diff --git a/resources/sass/bo/bo.scss b/resources/sass/bo/bo.scss index eb37f2b..ca97517 100644 --- a/resources/sass/bo/bo.scss +++ b/resources/sass/bo/bo.scss @@ -10,7 +10,3 @@ @import "./base/bootstrap-overload"; @import "./base/fonts"; @import "./base/common"; - -#sidebar-menu > .sticky-top { - top: 4rem !important; -} diff --git a/resources/sass/bo/pages/.gitkeep b/resources/sass/bo/pages/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/resources/sass/bo/partials/.gitkeep b/resources/sass/bo/partials/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/resources/sass/bo/vendor/_bootstrap.scss b/resources/sass/bo/vendor/_bootstrap.scss index 52f2a1a..85c6a32 100644 --- a/resources/sass/bo/vendor/_bootstrap.scss +++ b/resources/sass/bo/vendor/_bootstrap.scss @@ -37,6 +37,7 @@ @import "~/bootstrap/scss/card"; @import "~/bootstrap/scss/breadcrumb"; @import "~/bootstrap/scss/badge"; +@import "~/bootstrap/scss/modal"; // 6. Optionally include utilities API last to generate classes based on the Sass map in `_utilities.scss` @import "~/bootstrap/scss/utilities/api"; diff --git a/resources/ts/bo/components/BelongsToManyDropdownComponent.vue b/resources/ts/bo/components/BelongsToManyDropdownComponent.vue deleted file mode 100644 index bda8283..0000000 --- a/resources/ts/bo/components/BelongsToManyDropdownComponent.vue +++ /dev/null @@ -1,255 +0,0 @@ - - - - - diff --git a/resources/ts/bo/components/ClaimActionsComponent.vue b/resources/ts/bo/components/ClaimActionsComponent.vue new file mode 100644 index 0000000..231a841 --- /dev/null +++ b/resources/ts/bo/components/ClaimActionsComponent.vue @@ -0,0 +1,494 @@ + + + diff --git a/resources/ts/bo/components/ClaimConversationComponent.vue b/resources/ts/bo/components/ClaimConversationComponent.vue new file mode 100644 index 0000000..53938b5 --- /dev/null +++ b/resources/ts/bo/components/ClaimConversationComponent.vue @@ -0,0 +1,263 @@ +