2023-02-22 11:51:36 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
2023-06-21 10:24:56 +00:00
|
|
|
use App\Enums\Promotions\SourceEnum;
|
|
|
|
|
use App\Enums\Promotions\TargetEnum;
|
|
|
|
|
use App\Enums\Promotions\AngleEnum;
|
|
|
|
|
use App\Enums\Promotions\EventEnum;
|
2023-02-23 16:23:00 +01:00
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
2023-02-22 11:51:36 +01:00
|
|
|
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
|
2023-02-23 16:23:00 +01:00
|
|
|
* @property Brand $brand
|
2023-02-22 11:51:36 +01:00
|
|
|
*/
|
|
|
|
|
class Promo extends Model
|
|
|
|
|
{
|
2023-02-23 16:23:00 +01:00
|
|
|
use HasFactory;
|
|
|
|
|
|
2023-02-22 11:51:36 +01:00
|
|
|
/**
|
|
|
|
|
* @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 = [
|
2023-06-21 10:24:56 +00:00
|
|
|
'source' => SourceEnum::class,
|
|
|
|
|
'target' => TargetEnum::class,
|
|
|
|
|
'angle' => AngleEnum::class,
|
|
|
|
|
'event' => EventEnum::class,
|
2023-02-22 11:51:36 +01:00
|
|
|
'date' => 'datetime:Y-m-d',
|
|
|
|
|
'created_at' => 'datetime:Y-m-d',
|
|
|
|
|
'updated_at' => 'datetime:Y-m-d',
|
|
|
|
|
'deleted_at' => 'datetime:Y-m-d',
|
|
|
|
|
];
|
|
|
|
|
|
2023-02-23 16:23:00 +01:00
|
|
|
/**
|
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
|
|
|
|
*/
|
|
|
|
|
public function brands()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsToMany('App\Models\Brand', 'promo_brands');
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-22 11:51:36 +01:00
|
|
|
/**
|
|
|
|
|
* @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');
|
|
|
|
|
}
|
|
|
|
|
}
|