46 lines
920 B
PHP
46 lines
920 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Enums\CampaignTypes;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
|
|
class Campaign extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var array<int, string>
|
|
*/
|
|
protected $fillable = [
|
|
'name',
|
|
'type',
|
|
'status',
|
|
'brand_id'
|
|
];
|
|
|
|
/**
|
|
* The attributes that should be cast.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $casts = [
|
|
'type' => CampaignTypes::class,
|
|
'status' => 'bool'
|
|
];
|
|
|
|
public function brand(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Brand::class);
|
|
}
|
|
|
|
public function coupons(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Coupon::class);
|
|
}
|
|
}
|