feat: 🗃️ add claims tables, seeder and relations

This commit is contained in:
Alexis Gousseau 2025-07-24 11:32:12 +02:00
parent af090bbef7
commit a3a84446f8
No known key found for this signature in database
GPG key ID: 4A614CB3DBBA2406
53 changed files with 1262 additions and 115 deletions

View file

@ -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'
]);

View file

@ -0,0 +1,21 @@
<?php
namespace App\Enums\Claims;
use App\Traits\Enums\BaseEnum;
enum ClaimMessageType: int
{
use BaseEnum;
case auto = 1;
case human = 2;
/**
* Optionnal labels definition
*/
private const LABELS = [
self::auto->name => 'Automatique',
self::human->name => 'Humain',
];
}

View file

@ -0,0 +1,25 @@
<?php
namespace App\Enums\Claims;
use App\Traits\Enums\BaseEnum;
enum ClaimStatus: int
{
use BaseEnum;
case untreated = 1;
case treated = 2;
case sentDigital = 3;
case sentMarketing = 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',
];
}

View file

@ -0,0 +1,23 @@
<?php
namespace App\Enums\Claims;
use App\Traits\Enums\BaseEnum;
enum ClaimType: int
{
use BaseEnum;
case classic = 1;
case br = 2;
case rgpd = 3;
/**
* Optionnal labels definition
*/
private const LABELS = [
self::classic->name => 'Classique',
self::br->name => 'BR',
self::rgpd->name => 'RGPD',
];
}

View file

@ -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',
];
}

View file

@ -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')
];
}
}

View file

@ -51,7 +51,7 @@ class ActivityLog extends Model
/**
* The attributes that should be cast.
*
* @var array<string, string>
* @var array<string, mixed>
*/
protected $casts = [
'is_anonymous' => 'bool',

View file

@ -22,7 +22,7 @@ class Answer extends Model
/**
* The attributes that are mass assignable.
*
* @var string[]
* @var array<int, string>
*/
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
*/

View file

@ -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<App\Models\Service>
* $services Service HasMany relation.
@ -40,10 +44,14 @@ class Brand extends Model
/**
* The attributes that are mass assignable.
*
* @var string[]
* @var array<int, string>
*/
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<int, string>
*/
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
/**

View file

@ -28,7 +28,7 @@ class BrandStat extends Model
/**
* The attributes that are mass assignable.
*
* @var string[]
* @var array<int, string>
*/
protected $fillable = [
'active',
@ -42,7 +42,7 @@ class BrandStat extends Model
/**
* The attributes that should be cast to native types.
*
* @var array
* @var array<string, mixed>
*/
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
*/

106
app/Models/Claim.php Normal file
View file

@ -0,0 +1,106 @@
<?php
namespace App\Models;
use App\Enums\Claims\ClaimStatus;
use App\Enums\Claims\ClaimType;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
/**
* @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.
*/
class Claim extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
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<string, mixed>
*/
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);
}
}

View file

@ -0,0 +1,42 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
/**
* @property integer $id Mail template id.
* @property string $label Mail template label.
* @property string $content Mail template content.
* @property \App\Models\Brand $brand_id Mail template associated Brand.
* @property-read \Illuminate\Support\Carbon $created_at Mail template created date.
* @property-read \Illuminate\Support\Carbon $updated_at Mail template updated date.
*/
class ClaimMailTemplate extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
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);
}
}

View file

@ -0,0 +1,62 @@
<?php
namespace App\Models;
use App\Enums\Claims\ClaimMessageType;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
/**
* @property integer $id Subject id.
* @property string $label Subject label.
* @property \App\Models\Claim $claim_id Subject associated Claim.
* @property-read \Illuminate\Support\Carbon $created_at Subject created date.
* @property-read \Illuminate\Support\Carbon $updated_at Subject updated date.
*/
class ClaimMessage extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'content',
'type',
'claim_id',
'user_id',
];
/**
* The attributes that should be cast.
*
* @var array<string, mixed>
*/
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);
}
}

View file

@ -0,0 +1,50 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
/**
* @property integer $id Subject id.
* @property string $label Subject label.
* @property \App\Models\Brand $brand_id Subject associated Brand.
* @property-read \Illuminate\Support\Carbon $created_at Subject created date.
* @property-read \Illuminate\Support\Carbon $updated_at Subject updated date.
*/
class ClaimSubject extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
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);
}
}

View file

@ -36,7 +36,7 @@ class Customer extends Model
/**
* The attributes that are mass assignable.
*
* @var string[]
* @var array<int, string>
*/
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
/**

View file

@ -36,7 +36,7 @@ class CustomerInfo extends Model
/**
* The attributes that are mass assignable.
*
* @var string[]
* @var array<int, string>
*/
protected $fillable = [
'firstname',
@ -54,7 +54,7 @@ class CustomerInfo extends Model
/**
* The attributes that should be cast to native types.
*
* @var array
* @var array<string, mixed>
*/
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
*/

View file

@ -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<int, string>
*/
protected $fillable = [
'password',
];
/**
* The model's attributes.
*
* @var array<string, mixed>
*/
protected $attributes = [
'status' => false,
];
/**
* The attributes that should be cast to native types.
*
* @var array
* @var array<string, mixed>
*/
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
*/

View file

@ -30,7 +30,7 @@ class CustomerOptInHistory extends Model
/**
* The attributes that should be cast to native types.
*
* @var array
* @var array<string, mixed>
*/
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
*/

View file

@ -26,7 +26,7 @@ class Question extends Model
/**
* The attributes that are mass assignable.
*
* @var string[]
* @var array<int, string>
*/
protected $fillable = [
'question',
@ -37,7 +37,7 @@ class Question extends Model
/**
* Map attribute names to enum classes.
*
* @var array
* @var array<string, mixed>
*/
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
*/

View file

@ -44,7 +44,7 @@ class Service extends Model
/**
* The attributes that are mass assignable.
*
* @var string[]
* @var array<int, string>
*/
protected $fillable = [
'name',
@ -54,7 +54,7 @@ class Service extends Model
/**
* The attributes that should be cast to native types.
*
* @var array
* @var array<string, mixed>
*/
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<int, string>
*/
protected function getCacheBaseTags(): array
{

View file

@ -24,7 +24,7 @@ class ServiceStat extends Model
/**
* The attributes that are mass assignable.
*
* @var string[]
* @var array<int, string>
*/
protected $fillable = [
'date',
@ -33,7 +33,7 @@ class ServiceStat extends Model
/**
* The model's attributes.
*
* @var array
* @var array<string, mixed>
*/
protected $attributes = [
'nb_calls' => 0,
@ -42,7 +42,7 @@ class ServiceStat extends Model
/**
* Map attribute names to enum classes.
*
* @var array
* @var array<string, mixed>
*/
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
*/

View file

@ -44,7 +44,7 @@ class SingleOptin extends Model
/**
* The attributes that are mass assignable.
*
* @var string[]
* @var array<int, string>
*/
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
*/

View file

@ -55,7 +55,7 @@ class User extends Authenticatable
/**
* The attributes that should be cast.
*
* @var array<string, string>
* @var array<string, mixed>
*/
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');
}
}

View file

@ -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:

View file

@ -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",

270
composer.lock generated
View file

@ -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",

View file

@ -19,7 +19,7 @@ class AnswerFactory extends Factory
*
* @return array
*/
public function definition()
public function definition(): array
{
return [
'answer' => $this->faker->realText(20),

View file

@ -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,
];
}
}

View file

@ -0,0 +1,44 @@
<?php
namespace Database\Factories;
use App\Enums\Claims\ClaimStatus;
use App\Enums\Claims\ClaimType;
use App\Models\Brand;
use App\Models\Claim;
use App\Models\ClaimSubject;
use App\Models\Customer;
use Illuminate\Database\Eloquent\Factories\Factory;
class ClaimFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Claim::class;
/**
* Define the model's default state.
*
* @return array
*/
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,
];
}
}

View file

@ -0,0 +1,31 @@
<?php
namespace Database\Factories;
use App\Models\Brand;
use App\Models\ClaimMailTemplate;
use Illuminate\Database\Eloquent\Factories\Factory;
class ClaimMailTemplateFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = ClaimMailTemplate::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition(): array
{
return [
'label' => $this->faker->word(),
'content' => $this->faker->sentence(10),
'brand_id' => $this->faker->randomElement(Brand::pluck('id')),
];
}
}

View file

@ -0,0 +1,34 @@
<?php
namespace Database\Factories;
use App\Enums\Claims\ClaimMessageType;
use App\Models\Claim;
use App\Models\ClaimMessage;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
class ClaimMessageFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = ClaimMessage::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition(): array
{
return [
'content' => $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,
];
}
}

View file

@ -0,0 +1,30 @@
<?php
namespace Database\Factories;
use App\Models\Brand;
use App\Models\ClaimSubject;
use Illuminate\Database\Eloquent\Factories\Factory;
class ClaimSubjectFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = ClaimSubject::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition(): array
{
return [
'label' => $this->faker->word(),
'brand_id' => $this->faker->randomElement(Brand::pluck('id')),
];
}
}

View file

@ -19,7 +19,7 @@ class CustomerFactory extends Factory
*
* @return array
*/
public function definition()
public function definition(): array
{
return [
'email' => preg_replace(

View file

@ -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
];
}
}

View file

@ -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
];
}
}

View file

@ -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,
];
}
}

View file

@ -19,7 +19,7 @@ class ServiceFactory extends Factory
*
* @return array
*/
public function definition()
public function definition(): array
{
return [
'name' => $this->faker->lexify('?????????')

View file

@ -13,13 +13,13 @@ class UserFactory extends Factory
*
* @return array<string, mixed>
*/
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),

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

View file

@ -0,0 +1,44 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::table('brands', function (Blueprint $table) {
$table->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');
});
}
};

View file

@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('brand_users', function (Blueprint $table) {
$table->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');
}
};

View file

@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('claim_mail_templates', function (Blueprint $table) {
$table->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');
}
};

View file

@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('claim_subjects', function (Blueprint $table) {
$table->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');
}
};

View file

@ -0,0 +1,53 @@
<?php
use App\Enums\Claims\ClaimStatus;
use App\Enums\Claims\ClaimType;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('claims', function (Blueprint $table) {
$table->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');
}
};

View file

@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('claim_messages', function (Blueprint $table) {
$table->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');
}
};

View file

@ -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) {

View file

@ -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;

View file

@ -0,0 +1,19 @@
<?php
namespace Database\Seeders;
use App\Models\ClaimMailTemplate;
use Illuminate\Database\Seeder;
class ClaimMailTemplateSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run(): void
{
ClaimMailTemplate::factory(20)->create();
}
}

View file

@ -0,0 +1,19 @@
<?php
namespace Database\Seeders;
use App\Models\ClaimMessage;
use Illuminate\Database\Seeder;
class ClaimMessageSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run(): void
{
ClaimMessage::factory(20)->create();
}
}

View file

@ -0,0 +1,19 @@
<?php
namespace Database\Seeders;
use App\Models\Claim;
use Illuminate\Database\Seeder;
class ClaimSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run(): void
{
Claim::factory(20)->create();
}
}

View file

@ -0,0 +1,19 @@
<?php
namespace Database\Seeders;
use App\Models\ClaimSubject;
use Illuminate\Database\Seeder;
class ClaimSubjectSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run(): void
{
ClaimSubject::factory(20)->create();
}
}

View file

@ -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,
]);
}
}

View file

@ -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);
});
}
}