| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?php
- namespace App\Models;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Database\Eloquent\Relations\BelongsTo;
- use Illuminate\Database\Eloquent\Relations\HasMany;
- use Illuminate\Database\Eloquent\Relations\HasOne;
- use Illuminate\Database\Eloquent\SoftDeletes;
- /**
- * @property int $id
- * @property int $schedule_id
- * @property string $address_type
- * @property int $service_type_id
- * @property string|null $description
- * @property numeric $min_price
- * @property numeric $max_price
- * @property bool $offers_meal
- * @property \Illuminate\Support\Carbon|null $created_at
- * @property \Illuminate\Support\Carbon|null $updated_at
- * @property \Illuminate\Support\Carbon|null $deleted_at
- * @property-read \App\Models\Schedule $schedule
- * @property-read \App\Models\ServiceType|null $serviceType
- * @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\CustomScheduleSpeciality> $specialities
- * @property-read int|null $specialities_count
- * @method static \Illuminate\Database\Eloquent\Builder<static>|CustomSchedule newModelQuery()
- * @method static \Illuminate\Database\Eloquent\Builder<static>|CustomSchedule newQuery()
- * @method static \Illuminate\Database\Eloquent\Builder<static>|CustomSchedule onlyTrashed()
- * @method static \Illuminate\Database\Eloquent\Builder<static>|CustomSchedule query()
- * @method static \Illuminate\Database\Eloquent\Builder<static>|CustomSchedule whereAddressType($value)
- * @method static \Illuminate\Database\Eloquent\Builder<static>|CustomSchedule whereCreatedAt($value)
- * @method static \Illuminate\Database\Eloquent\Builder<static>|CustomSchedule whereDeletedAt($value)
- * @method static \Illuminate\Database\Eloquent\Builder<static>|CustomSchedule whereDescription($value)
- * @method static \Illuminate\Database\Eloquent\Builder<static>|CustomSchedule whereId($value)
- * @method static \Illuminate\Database\Eloquent\Builder<static>|CustomSchedule whereMaxPrice($value)
- * @method static \Illuminate\Database\Eloquent\Builder<static>|CustomSchedule whereMinPrice($value)
- * @method static \Illuminate\Database\Eloquent\Builder<static>|CustomSchedule whereOffersMeal($value)
- * @method static \Illuminate\Database\Eloquent\Builder<static>|CustomSchedule whereScheduleId($value)
- * @method static \Illuminate\Database\Eloquent\Builder<static>|CustomSchedule whereServiceTypeId($value)
- * @method static \Illuminate\Database\Eloquent\Builder<static>|CustomSchedule whereUpdatedAt($value)
- * @method static \Illuminate\Database\Eloquent\Builder<static>|CustomSchedule withTrashed(bool $withTrashed = true)
- * @method static \Illuminate\Database\Eloquent\Builder<static>|CustomSchedule withoutTrashed()
- * @mixin \Eloquent
- */
- class CustomSchedule extends Model
- {
- use SoftDeletes;
- protected $fillable = [
- 'schedule_id',
- 'address_type',
- 'service_type_id',
- 'description',
- 'min_price',
- 'max_price',
- 'offers_meal',
- ];
- protected $casts = [
- 'min_price' => 'decimal:2',
- 'max_price' => 'decimal:2',
- 'offers_meal' => 'boolean',
- ];
- public function schedule(): BelongsTo
- {
- return $this->belongsTo(Schedule::class);
- }
- public function serviceType(): HasOne
- {
- return $this->hasOne(ServiceType::class, 'id', 'service_type_id')->select('id', 'description');
- }
- public function specialities(): HasMany
- {
- return $this->hasMany(CustomScheduleSpeciality::class, 'custom_schedule_id', 'id')->leftJoin('specialities', 'custom_schedules_specialities.speciality_id', '=', 'specialities.id')
- ->select('specialities.id', 'specialities.description', 'custom_schedules_specialities.custom_schedule_id');
- }
- }
|