2021-04-08 15:49:20 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
|
|
class Promotion extends Model
|
|
|
|
|
{
|
|
|
|
|
use HasFactory;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The attributes that should be cast to native types.
|
|
|
|
|
*
|
|
|
|
|
* @var array
|
|
|
|
|
*/
|
|
|
|
|
protected $casts = [
|
|
|
|
|
'date_start' => 'datetime',
|
|
|
|
|
'date_end' => 'datetime',
|
|
|
|
|
];
|
|
|
|
|
|
2022-09-03 16:56:16 +02:00
|
|
|
/**
|
|
|
|
|
* BelongsToMany products relation
|
|
|
|
|
*
|
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
|
|
|
|
*/
|
2021-04-08 15:49:20 +02:00
|
|
|
public function products()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsToMany(Product::class);
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-03 16:56:16 +02:00
|
|
|
/**
|
|
|
|
|
* BelongsTo discountType relation
|
|
|
|
|
*
|
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
|
|
|
*/
|
2021-04-08 15:49:20 +02:00
|
|
|
public function discountType()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(DiscountType::class, 'discount_type_id');
|
|
|
|
|
}
|
|
|
|
|
}
|