ldc-boutique-cnc/app/Models/TimeslotSetting.php
2022-12-19 16:20:00 +01:00

80 lines
2.5 KiB
PHP

<?php
namespace App\Models;
use App\Casts\IntToEpochCast;
use App\Enums\TimeSlot\WeekDay;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Kwaadpepper\Enum\Traits\CastsEnums;
/**
* TimeslotSetting
*
* @property \App\Enums\TimeSlot\WeekDay $day Jour de la semaine concernée par cette configuration.
* @property string|null $morning_start A string like "hh:ii". Début période matin.
* @property string|null $morning_end A string like "hh:ii". Fin période matin.
* @property string|null $afternoon_start A string like "hh:ii". Début période après-midi.
* @property string|null $afternoon_end A string like "hh:ii". Fin période après-midi.
* @property string|null $interval A string like "hh:ii". Durée entre les créneaux.
* @property string|null $min_order_preparation A string like "hh:ii". Durée de préparation
* de commande
* @property integer|null $max_orders_per_interval Nombre max de commadnes par intervalles.
*
* @package App\Models
*/
class TimeslotSetting extends Model
{
use CastsEnums;
use HasFactory;
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'morning_start' => IntToEpochCast::class,
'morning_end' => IntToEpochCast::class,
'afternoon_start' => IntToEpochCast::class,
'afternoon_end' => IntToEpochCast::class,
'interval' => IntToEpochCast::class,
'min_order_preparation' => IntToEpochCast::class,
];
/**
* Map attribute names to enum classes.
*
* @var array
*/
protected $enumCasts = [
'day' => WeekDay::class
];
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'morning_start',
'morning_end',
'afternoon_start',
'afternoon_end',
'interval',
'min_order_preparation',
'max_orders_per_interval',
];
// * RELATIIONSHIPS
/**
* BelongsTo shop relation
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function shop()
{
return $this->belongsTo(Shop::class);
}
}