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

46 lines
976 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;
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'type' => CampaignTypes::class,
];
2023-11-24 15:35:08 +01:00
// * RELATIONS
/**
* Get the brand that owns the Campaign
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function brand(): BelongsTo
{
2023-09-13 16:48:17 +02:00
return $this->belongsTo(Brand::class);
}
2023-11-24 15:35:08 +01:00
/**
* Get coupons that owned by the Campaign
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function coupons(): BelongsToMany
2023-09-13 16:48:17 +02:00
{
return $this->belongsToMany(Coupon::class);
}
}