ldc-mesbr-app/app/Models/Campaign.php
2023-12-01 15:27:30 +01:00

58 lines
1.5 KiB
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;
/**
* Campaign
*
* @property integer $id Campaign Id.
* @property string $name The campaign name.
* @property App\Enums\CampaignTypes $type The type of the campaign.
* @property boolean $status If the campagin is published or not.
* @property integer $brand_id The brand id of the campaign.
*
* * RELATIONS
* @property-read App\Models\Brand $brand The brand that owns the Campaign.
* @property-read App\Models\Coupon $coupon Coupons that owned by the Campaign.
*/
class Campaign extends Model
{
use HasFactory;
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'type' => CampaignTypes::class,
];
// * RELATIONS
/**
* Get the brand that owns the Campaign
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function brand(): BelongsTo
{
return $this->belongsTo(Brand::class);
}
/**
* Get coupons that owned by the Campaign
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function coupons(): BelongsToMany
{
return $this->belongsToMany(Coupon::class);
}
}