%PDF- %PDF-
Direktori : /home/forge/api-takeaseat.eco-n-tech.co.uk/app/Models/ |
Current File : //home/forge/api-takeaseat.eco-n-tech.co.uk/app/Models/Availability.php |
<?php namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; class Availability extends Model { use HasFactory; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'therapist_id', 'available_from', 'available_to', 'increment_id', 'address_id' ]; /** * The attributes that should be cast. * * @var array */ protected $casts = [ 'available_from' => 'datetime:Y-m-d H:i:s', 'available_to' => 'datetime:Y-m-d H:i:s' ]; /** * List of increments * * @var array */ const INCREMENTS = [ 1 => '60', 2 => '30', 3 => '15' ]; /** * Get the availability session types */ public function sessions() { return $this->belongsToMany(Session::class, 'availability_sessions', 'availability_id', 'session_id'); } /** * Get the therapist attached */ public function therapist() { return $this->belongsTo(Therapist::class); } /** * Get the bookings already matching this availability */ public function bookings() { return $this->hasMany(Booking::class, 'therapist_id', 'therapist_id') ->where('therapist_id', $this->therapist->id) ->where('status', '!=', 3); } /** * Get the address attached to this availability */ public function address() { return $this->hasOne(UserAddress::class, 'id', 'address_id'); } }