ldc-mesbr-app/app/Models/Campaign.php

47 lines
920 B
PHP
Raw Normal View History

2023-09-13 16:48:17 +02:00
<?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;
2023-09-14 16:00:27 +02:00
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'name',
'type',
'status',
'brand_id'
];
2023-09-13 16:48:17 +02:00
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'type' => CampaignTypes::class,
2023-09-14 16:00:27 +02:00
'status' => 'bool'
2023-09-13 16:48:17 +02:00
];
2023-09-14 16:00:27 +02:00
public function brand(): BelongsTo
{
2023-09-13 16:48:17 +02:00
return $this->belongsTo(Brand::class);
}
2023-09-14 16:00:27 +02:00
public function coupons(): BelongsToMany
2023-09-13 16:48:17 +02:00
{
return $this->belongsToMany(Coupon::class);
}
}