Spaces:
Running
Running
| namespace App\Models; | |
| use App\Services\ChapterServices; | |
| use App\Services\HashtagServices; | |
| use App\Services\TaggedServices; | |
| use Illuminate\Database\Eloquent\Factories\HasFactory; | |
| use Illuminate\Database\Eloquent\Model; | |
| use Spatie\Sluggable\HasSlug; | |
| use Spatie\Sluggable\SlugOptions; | |
| use App\Models\Traits\SearchableTraitExtend; | |
| class Amenity extends BaseModel | |
| { | |
| protected $hidden = ['pivot']; | |
| protected $table = "amenities"; | |
| protected $fillable =[ | |
| 'price', | |
| 'name', | |
| 'description', | |
| 'image', | |
| 'created_by', | |
| 'updated_by', | |
| 'created_at', | |
| 'updated_at', | |
| ]; | |
| const TIME = [ | |
| 'application_date', | |
| 'attendance_start_at', | |
| 'attendance_end_at', | |
| 'approved_at' | |
| ]; | |
| public static function boot() | |
| { | |
| parent::boot(); | |
| static::deleting(function ($model) { | |
| $roomTypes = $model->roomTypes; | |
| if(!$roomTypes->isEmpty() ){ | |
| return false; | |
| } | |
| $model->amenityRoomTypes()->delete(); | |
| }); | |
| } | |
| // public function getSlugOptions() : SlugOptions | |
| // { | |
| // return SlugOptions::create() | |
| // ->generateSlugsFrom('comic_name') | |
| // ->saveSlugsTo('slug'); | |
| // } | |
| public function roomTypes(){ | |
| return $this->belongsToMany(RoomType::class,'amenity_room_type','amenity_id','room_type_id'); | |
| } | |
| public function amenityRoomTypes(){ | |
| return $this->hasMany(AmenityRoomType::class,'amenity_id'); | |
| } | |
| } | |