public static function boot() { parent::boot(); static::creating(function ($model) { return $model->validate(); }); static::updating(function ($model) { return $model->validate(); }); static::deleted(function ($model) { $model->file->delete(); }); }
public static function boot() { parent::boot(); /* validation required on new */ static::creating(function ($model) { if (!$model->validate()) { return false; } return true; }); static::updating(function ($model) { if (!$model->validate()) { return false; } return true; }); }
public static function boot() { parent::boot(); static::creating(function ($model) { if (!$model->validate()) { return false; } return true; }); static::created(function ($model) { event(new DepartmentCreated($model)); return true; }); static::updating(function ($model) { if (!$model->validate()) { return false; } return true; }); }
public static function boot() { parent::boot(); static::creating(function ($model) { if (!$model->validate()) { return false; } return true; }); static::updating(function ($model) { if (!$model->validate()) { return false; } return true; }); static::deleted(function ($model) { \File::delete(getcwd() . "/uploads/" . $model->fileCategory->name . "/" . $model->filename); return true; }); }
public static function boot() { parent::boot(); static::creating(function ($model) { if (!$model->validate()) { return false; } return true; }); static::created(function ($model) { $result = \File::makeDirectory(getcwd() . "/uploads/" . $model->name); return $result; }); static::updating(function ($model) { if (!$model->validate()) { return false; } return true; }); }
public static function boot() { parent::boot(); static::creating(function ($model) { if (!$model->validate()) { return false; } return true; }); static::created(function ($model) { event(new MotionCreated($model)); return true; }); static::updating(function ($model) { if (!$model->validate()) { return false; } event(new MotionUpdated($model)); return true; }); static::deleting(function ($model) { // before delete() method call this $model->votes()->delete(); $model->files()->delete(); }); }
/** * @return Overrides the API Model, will see if it can be intergrated into it */ public function getVisibleAttribute() { if (!Auth::check()) { return $this->visible; } if (Auth::user()->id == $this->id) { // Logged in user $this->visible = array_unique(array_merge($this->creatorVisible, $this->visible)); } if ($this->public) { //Public profile $this->visible = array_unique(array_merge($this->publicVisible, $this->visible)); } return parent::getVisibleAttribute(); }
public function toArray() { $this->getVisibleAttribute(); return parent::toArray(); }
/** * @return Overrides the API Model, will see if it can be intergrated into it */ public function getVisibleAttribute() { //Should be manually run because ... fill this in if you can think of a reason if (Auth::user()->id == $this->user_id) { $this->setVisible = array_unique(array_merge($this->creatorVisible, $this->visible)); } if ($this->user && $this->user->public) { //I'm really confused how a vote can not have a user somehow $this->setVisible = array_unique(array_merge($this->publicVisible, $this->visible)); } return parent::getVisibleAttribute(); }
/** * @return Overrides the API Model, will see if it can be intergrated into it */ public function getVisibleAttribute() { if (!Auth::check()) { return $this->visible; } return parent::getVisibleAttribute(); }
public static function boot() { parent::boot(); /* validation required on new */ static::creating(function ($model) { event(new CommentVoteCreated($model)); return $model->validate(); }); static::updating(function ($model) { event(new CommentVoteUpdated($model)); return $model->validate(); }); static::deleted(function ($model) { event(new CommentVoteDeleted($model)); return true; }); }