belongsToMany(Event::class, 'event_attenders', 'attender_id', 'event_id'); } /* |-------------------------------------------------------------------------- | SCOPES |-------------------------------------------------------------------------- */ /* |-------------------------------------------------------------------------- | ACCESSORS |-------------------------------------------------------------------------- */ /* |-------------------------------------------------------------------------- | MUTATORS |-------------------------------------------------------------------------- */ public function setFileAttribute($value) { $attribute_name = "file"; $disk = "public"; $destination_path = "files/uploads"; $this->uploadFileToDisk($value, $attribute_name, $disk, $destination_path, $fileName = null); } public static function boot() { parent::boot(); static::deleting(function($obj) { if($obj->file){ \Storage::disk('public')->delete($obj->file); } }); } }