Merge branch 'models' into 'develop'

add models generate from database

See merge request ldc-web/projets/startcoq!4
This commit is contained in:
Vincent BRIDIER 2023-02-23 15:22:44 +00:00
commit b600a890aa
17 changed files with 1834 additions and 262 deletions

30
app/Casts/JsonCast.php Normal file
View file

@ -0,0 +1,30 @@
<?php
namespace App\Casts;
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
use Illuminate\Database\Eloquent\Model;
class JsonCast implements CastsAttributes
{
/**
* Cast the given value.
*
* @param array<string, mixed> $attributes
* @return array<string, mixed>
*/
public function get(Model $model, string $key, mixed $value, array $attributes): array
{
return json_decode($value, true);
}
/**
* Prepare the given value for storage.
*
* @param array<string, mixed> $attributes
*/
public function set(Model $model, string $key, mixed $value, array $attributes): string
{
return json_encode($value);
}
}

30
app/Models/Brand.php Normal file
View file

@ -0,0 +1,30 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* @property integer $id
* @property string $brand
* @property string $filter
* @property Promo[] $promos
*/
class Brand extends Model
{
/**
* @var array
*/
protected $fillable = [
'brand',
'filter'
];
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function promos()
{
return $this->hasMany('App\Models\Promo');
}
}

78
app/Models/Ingredient.php Normal file
View file

@ -0,0 +1,78 @@
<?php
namespace App\Models;
use App\Casts\JsonCast;
use App\Enums\Ingredients\IngredientOriginEnum;
use App\Enums\Ingredients\IngredientFamilyEnum;
use Illuminate\Database\Eloquent\Model;
/**
* @property integer $id
* @property integer $user_id
* @property string $name
* @property string $supplier
* @property boolean $origin
* @property boolean $is_sample
* @property boolean $family
* @property string $packing
* @property string $function
* @property string $observation
* @property string $picture
* @property string $url
* @property string $documents
* @property string $fair
* @property string $created_at
* @property string $updated_at
* @property string $deleted_at
* @property User $user
*/
class Ingredient extends Model
{
/**
* @var array
*/
protected $fillable = [
'user_id',
'name',
'supplier',
'origin',
'is_sample',
'family',
'packing',
'function',
'observation',
'picture',
'url',
'documents',
'fair',
'created_at',
'updated_at',
'deleted_at'
];
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'origin' => IngredientOriginEnum::class,
'is_sample' => 'boolean',
'family' => IngredientFamilyEnum::class,
'packing' => JsonCast::class,
'function' => JsonCast::class,
'documents' => JsonCast::class,
'created_at' => 'datetime:Y-m-d',
'updated_at' => 'datetime:Y-m-d',
'deleted_at' => 'datetime:Y-m-d',
];
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
{
return $this->belongsTo('App\Models\User');
}
}

44
app/Models/Keyword.php Normal file
View file

@ -0,0 +1,44 @@
<?php
namespace App\Models;
use App\Enums\KeywordCategoryEnum;
use Illuminate\Database\Eloquent\Model;
/**
* @property integer $id
* @property string $label
* @property string $keyword_cat
* @property string $created_at
* @property string $updated_at
* @property Keywordable[] $keywordables
*/
class Keyword extends Model
{
/**
* @var array
*/
protected $fillable = [
'label',
'keyword_cat',
'created_at',
'updated_at'
];
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'keyword_cat' => KeywordCategoryEnum::class
];
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function keywordables()
{
return $this->hasMany('App\Models\Keywordable');
}
}

View file

@ -0,0 +1,36 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* @property integer $id
* @property integer $keyword_id
* @property string $model
* @property integer $keywordable_id
* @property string $created_at
* @property string $updated_at
* @property Keyword $keyword
*/
class Keywordable extends Model
{
/**
* @var array
*/
protected $fillable = [
'keyword_id',
'model',
'keywordable_id',
'created_at',
'updated_at'
];
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function keyword()
{
return $this->belongsTo('App\Models\Keyword');
}
}

83
app/Models/Packaging.php Normal file
View file

@ -0,0 +1,83 @@
<?php
namespace App\Models;
use App\Enums\Packaging\PackagingOriginEnum;
use App\Enums\Packaging\PackagingWatchTypeEnum;
use App\Enums\Packaging\PackagingTypeEnum;
use App\Enums\Packaging\PackagingMaterialEnum;
use App\Enums\Packaging\PackagingBenefitEnum;
use Illuminate\Database\Eloquent\Model;
/**
* @property integer $id
* @property integer $user_id
* @property boolean $watch_type
* @property string $supplier
* @property string $name
* @property string $product_description
* @property boolean $origin
* @property boolean $is_sample
* @property boolean $type_packaging
* @property boolean $material
* @property boolean $benefit
* @property string $observation
* @property string $picture
* @property string $url
* @property string $documents
* @property string $fair
* @property string $created_at
* @property string $updated_at
* @property string $deleted_at
* @property User $user
*/
class Packaging extends Model
{
/**
* @var array
*/
protected $fillable = [
'user_id',
'watch_type',
'supplier',
'name',
'product_description',
'origin',
'is_sample',
'type_packaging',
'material',
'benefit',
'observation',
'picture',
'url',
'documents',
'fair',
'created_at',
'updated_at',
'deleted_at'
];
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'watch_type' => PackagingWatchTypeEnum::class,
'origin' => PackagingOriginEnum::class,
'is_sample' => 'boolean',
'type_packaging' => PackagingTypeEnum::class,
'material' => PackagingMaterialEnum::class,
'benefit' => PackagingBenefitEnum::class,
'picture' => JsonCast::class,
'documents' => JsonCast::class,
];
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
{
return $this->belongsTo('App\Models\User');
}
}

90
app/Models/Process.php Normal file
View file

@ -0,0 +1,90 @@
<?php
namespace App\Models;
use App\Enums\Process\ProcessWatchTypeEnum;
use App\Enums\Process\ProcessOriginEnum;
use App\Enums\Process\ProcessBenefitEnum;
use Illuminate\Database\Eloquent\Model;
/**
* @property integer $id
* @property integer $user_id
* @property boolean $watch_type
* @property string $supplier
* @property string $name
* @property string $description
* @property boolean $origin
* @property boolean $is_test_machine
* @property boolean $is_quotation
* @property string $quotation_document
* @property boolean $profit
* @property string $observation
* @property string $picture
* @property string $documents
* @property string $url
* @property string $created_at
* @property string $updated_at
* @property string $deleted_at
* @property ProcessHasProcessType[] $processHasProcessTypes
* @property User $user
*/
class Process extends Model
{
/**
* @var array
*/
protected $fillable = [
'user_id',
'watch_type',
'supplier',
'name',
'description',
'origin',
'is_test_machine',
'is_quotation',
'quotation_document',
'profit',
'observation',
'picture',
'documents',
'url',
'created_at',
'updated_at',
'deleted_at'
];
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'watch_type' => ProcessWatchTypeEnum::class,
'origin' => ProcessOriginEnum::class,
'is_test_machine' => 'boolean',
'is_quotation' => 'boolean',
'profit' => ProcessBenefitEnum::class,
'picture' => JsonCast::class,
'documents' => JsonCast::class,
'created_at' => 'datetime:Y-m-d',
'updated_at' => 'datetime:Y-m-d',
'deleted_at' => 'datetime:Y-m-d',
];
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function processHasProcessTypes()
{
return $this->hasMany('App\Models\ProcessHasProcessType');
}
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
{
return $this->belongsTo('App\Models\User');
}
}

View file

@ -0,0 +1,28 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* @property integer $id
* @property string $name
* @property ProcessHasProcessType[] $processHasProcessTypes
*/
class ProcessType extends Model
{
/**
* @var array
*/
protected $fillable = [
'name'
];
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function processHasProcessTypes()
{
return $this->hasMany('App\Models\ProcessHasProcessType');
}
}

121
app/Models/Product.php Normal file
View file

@ -0,0 +1,121 @@
<?php
namespace App\Models;
use App\Enums\Products\ProductSourceEnum;
use App\Enums\Products\ProductCertificationEnum;
use App\Enums\Products\ProductDistributionNetworkEnum;
use App\Enums\Products\ProductRayEnum;
use App\Enums\Products\ProductRangeEnum;
use App\Enums\Products\ProductGeoAreaEnum;
use Illuminate\Database\Eloquent\Model;
/**
* @property integer $id
* @property integer $user_id
* @property integer $brand_id
* @property string $name
* @property string $brand
* @property string $entry_date
* @property boolean $source
* @property string $fair
* @property string $shop
* @property string $catalogue
* @property string $gencod
* @property string $picture
* @property string $docs
* @property string $url
* @property boolean $certification
* @property string $origins
* @property string $claims
* @property string $specified_claim
* @property boolean $distribution_network
* @property boolean $ray
* @property boolean $product_range
* @property boolean $geo area
* @property integer $weight
* @property integer $pvc
* @property string $comment
* @property boolean $is_tasted
* @property integer $tasters_number
* @property string $created_at
* @property string $updated_at
* @property string $deleted_at
* @property ProductComment[] $productComments
* @property User $user
*/
class Product extends Model
{
/**
* @var array
*/
protected $fillable = [
'user_id',
'brand_id',
'name',
'brand',
'entry_date',
'source',
'fair',
'shop',
'catalogue',
'gencod',
'picture',
'docs',
'url',
'certification',
'origins',
'claims',
'specified_claim',
'distribution_network',
'ray',
'product_range',
'geo area',
'weight',
'pvc',
'comment',
'is_tasted',
'tasters_number',
'created_at',
'updated_at',
'deleted_at'
];
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'source' => ProductSourceEnum::class,
'docs' => JsonCast::class,
'certification' => ProductCertificationEnum::class,
'origins' => JsonCast::class,
'claims' => JsonCast::class,
'distribution_network' => ProductDistributionNetworkEnum::class,
'ray' => ProductRayEnum::class,
'product_range' => ProductRangeEnum::class,
'geo_area' => ProductGeoAreaEnum::class,
'is_tasted' => 'boolean',
'entry_date' => 'datetime:Y-m-d',
'created_at' => 'datetime:Y-m-d',
'updated_at' => 'datetime:Y-m-d',
'deleted_at' => 'datetime:Y-m-d',
];
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function productComments()
{
return $this->hasMany('App\Models\ProductComment');
}
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
{
return $this->belongsTo('App\Models\User');
}
}

View file

@ -0,0 +1,42 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* @property integer $id
* @property integer $product_id
* @property string $evaluation
* @property string $aspect
* @property string $taste
* @property string $odor
* @property string $texture
* @property string $created_at
* @property string $updated_at
* @property Product $product
*/
class ProductComment extends Model
{
/**
* @var array
*/
protected $fillable = [
'product_id',
'evaluation',
'aspect',
'taste',
'odor',
'texture',
'created_at',
'updated_at'
];
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function product()
{
return $this->belongsTo('App\Models\Product');
}
}

111
app/Models/Promo.php Normal file
View file

@ -0,0 +1,111 @@
<?php
namespace App\Models;
use App\Enums\Promotions\PromotionSourceEnum;
use App\Enums\Promotions\PromotionTargetEnum;
use App\Enums\Promotions\PromotionAngleEnum;
use App\Enums\Promotions\PromotionEventEnum;
use Illuminate\Database\Eloquent\Model;
/**
* @property integer $id
* @property integer $user_id
* @property integer $promo_type_id
* @property integer $promo_distribution_network_id
* @property integer $brand_id
* @property string $date
* @property boolean $source
* @property string $shop_name
* @property string $shop_city
* @property string $sector_chief
* @property string $name
* @property string $target
* @property string $angle
* @property string $event
* @property string $url
* @property string $press
* @property string $fair
* @property string $created_at
* @property string $updated_at
* @property string $deleted_at
* @property Brand[] $brands
* @property PromoType $promoType
* @property PromoDistributionNetwork $promoDistributionNetwork
* @property User $user
*/
class Promo extends Model
{
/**
* @var array
*/
protected $fillable = [
'user_id',
'promo_type_id',
'promo_distribution_network_id',
'brand_id',
'date',
'source',
'shop_name',
'shop_city',
'sector_chief',
'name',
'target',
'angle',
'event',
'url',
'press',
'fair',
'created_at',
'updated_at',
'deleted_at'
];
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'source' => PromotionSourceEnum::class,
'target' => PromotionTargetEnum::class,
'angle' => PromotionAngleEnum::class,
'event' => PromotionEventEnum::class,
'date' => 'datetime:Y-m-d',
'created_at' => 'datetime:Y-m-d',
'updated_at' => 'datetime:Y-m-d',
'deleted_at' => 'datetime:Y-m-d',
];
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function brand()
{
return $this->belongsTo('App\Models\Brand');
}
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function promoType()
{
return $this->belongsTo('App\Models\PromoType');
}
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function promoDistributionNetwork()
{
return $this->belongsTo('App\Models\PromoDistributionNetwork');
}
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
{
return $this->belongsTo('App\Models\User');
}
}

View file

@ -0,0 +1,44 @@
<?php
namespace App\Models;
use App\Enums\Promotions\PromotionDistributionNetworkEnum;
use Illuminate\Database\Eloquent\Model;
/**
* @property integer $id
* @property boolean $name
* @property string $label
* @property string $created_at
* @property string $updated_at
* @property Promo[] $promos
*/
class PromoDistributionNetwork extends Model
{
/**
* @var array
*/
protected $fillable = [
'name',
'label',
'created_at',
'updated_at'
];
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'name' => PromotionDistributionNetworkEnum::class
];
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function promos()
{
return $this->hasMany('App\Models\Promo');
}
}

51
app/Models/PromoType.php Normal file
View file

@ -0,0 +1,51 @@
<?php
namespace App\Models;
use App\Enums\Promotions\PromotionTypeEnum;
use Illuminate\Database\Eloquent\Model;
/**
* @property integer $id
* @property boolean $name
* @property string $label
* @property string $created_at
* @property string $updated_at
* @property Promo[] $promos
*/
class PromoType extends Model
{
/**
* Indicates if the IDs are auto-incrementing.
*
* @var bool
*/
public $incrementing = false;
/**
* @var array
*/
protected $fillable = [
'name',
'label',
'created_at',
'updated_at'
];
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'name' => PromotionTypeEnum::class
];
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function promos()
{
return $this->hasMany('App\Models\Promo');
}
}

65
app/Models/Survey.php Normal file
View file

@ -0,0 +1,65 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* @property integer $id
* @property integer $user_id
* @property string $name
* @property string $author
* @property string $comment
* @property string $date
* @property string $documents
* @property boolean $is_distributor
* @property boolean $is_customer
* @property boolean $type
* @property string $created_at
* @property string $updated_at
* @property string $deleted_at
* @property User $user
*/
class Survey extends Model
{
/**
* @var array
*/
protected $fillable = [
'user_id',
'name',
'author',
'comment',
'date',
'documents',
'is_distributor',
'is_customer',
'type',
'created_at',
'updated_at',
'deleted_at'
];
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'date' => 'datetime:Y-m-d',
'documents' => JsonCast::class,
'is_distributor' => 'boolean',
'is_customer' => 'boolean',
'created_at' => 'datetime:Y-m-d',
'updated_at' => 'datetime:Y-m-d',
'deleted_at' => 'datetime:Y-m-d',
];
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
{
return $this->belongsTo('App\Models\User');
}
}

View file

@ -2,7 +2,10 @@
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^8.1",
@ -18,7 +21,8 @@
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^7.0",
"phpunit/phpunit": "^10.0",
"spatie/laravel-ignition": "^2.0"
"spatie/laravel-ignition": "^2.0",
"krlove/eloquent-model-generator": "dev-l10-compatibility"
},
"autoload": {
"psr-4": {
@ -27,6 +31,12 @@
"Database\\Seeders\\": "database/seeders/"
}
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/laravel-shift/eloquent-model-generator.git"
}
],
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"

1228
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -185,6 +185,7 @@ return [
/*
* Package Service Providers...
*/
Krlove\EloquentModelGenerator\Provider\GeneratorServiceProvider::class,
/*
* Application Service Providers...