32 lines
602 B
PHP
32 lines
602 B
PHP
|
|
<?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',
|
||
|
|
];
|
||
|
|
|
||
|
|
public function products()
|
||
|
|
{
|
||
|
|
return $this->belongsToMany(Product::class);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function discountType()
|
||
|
|
{
|
||
|
|
return $this->belongsTo(DiscountType::class, 'discount_type_id');
|
||
|
|
}
|
||
|
|
}
|