/** * Removes a model from this relationship type. */ public function remove(Model $model, $sessionKey = null) { if ($sessionKey === null) { $options = $this->parent->getRelationDefinition($this->relationName); if (array_get($options, 'delete', false)) { $model->delete(); } else { /* * Make this model an orphan ;~( */ $model->setAttribute($this->getPlainForeignKey(), null); $model->setAttribute($this->getPlainMorphType(), null); $model->save(); } /* * Use the opportunity to set the relation in memory */ if ($this instanceof MorphOne) { $this->parent->setRelation($this->relationName, null); } else { $this->parent->reloadRelations($this->relationName); } } else { $this->parent->unbindDeferred($this->relationName, $model, $sessionKey); } }
/** * Delete the given model entity. * * @param Model $model Model to be deleted. * @param string $msg Message for a successful delete. * @param string $title Title for a successful delete. * * @return array */ protected function deleteThe(Model $model, $msg = 'messages.deleted', $title = 'messages.success') { if ($model->delete()) { return ['title' => trans("admin::{$title}"), 'msg' => trans("admin::{$msg}")]; } return reportError(); }
/** * Delete the model. * * @param \Illuminate\Database\Eloquent\Model $user * * @return bool * * @throws \Exception */ public function delete(Model $user) { if (auth()->user() && auth()->user()->id === $user->id) { abort(406); } return $user->delete(); }
public function delete() { foreach ($this->projects as $project) { $project->delete(); } parent::delete(); }
public function delete() { foreach (VendorItemPivot::byVendor($this->id)->get() as $object) { $object->delete(); } return parent::delete(); }
public function delete() { // Remove all relationships $this->memberships()->detach(); $this->medias()->detach(); $this->pricelists()->delete(); // Delete all media links foreach (ModuleMediaMembership::where('module_id', $this->id)->get() as $mmm) { $mmm->delete(); } // Remove all relationships $this->tags()->detach(); // Delete all images foreach ($this->images as $image) { $image->delete(); } // Delete all translations $this->translations()->delete(); // Delete asset images folder $upload_dir = \Config::get('redminportal::image.upload_dir'); $deleteFolder = new Image(); $url_path = RHelper::joinPaths($upload_dir, $this->table, $this->id); $deleteFolder->deleteFiles($url_path); return parent::delete(); }
/** * {@inheritdoc} */ public function delete() { if ($this->exists) { $this->tagged()->delete(); } return parent::delete(); }
/** * Delete Questions before deleting Group itself. * * @return bool|null * @throws \Exception */ public function delete() { $this->questions->each(function ($question) { $question->delete(); }); return parent::delete(); }
public function delete() { foreach ($this->photos as $photo) { File::delete($photo->path); } parent::delete(); }
/** * Delete Groups before deleting Section itself. * * @return bool|null * @throws \Exception */ public function delete() { $this->groups->each(function ($group) { $group->delete(); }); return parent::delete(); }
public function delete() { $this->is()->delete(); $this->photos()->delete(); // δεν είμαι σίγουρος αν διαγράφει ΟΛΕΣ τις φωτογραφίες parent::delete(); }
/** * Delete table data rate_cat and releted child rates */ public function delete() { // delete all related rates $this->rates()->delete(); // delete the rates_cat return parent::delete(); }
/** * 删除资源 * * @param \Illuminate\Database\Eloquent\Model $model * * @return mixed * @throws \Exception */ public function destroy(Model $model) { if ($model->delete()) { return $this->success('删除成功'); } return $this->error('删除失败'); }
/** * Deletes a blog post and all * the associated comments. * * @return bool */ public function delete() { // Delete the comments $this->comments()->delete(); // Delete the blog post return parent::delete(); }
/** * Delete an existing model. * * @throws Exception * @return mixed */ public function delete() { $this->beforeDelete(); $return = parent::delete(); $this->afterDelete($return); return $return; }
public function delete() { if ($this->featured_image != '') { $this->deleteImage($this->featured_image); } parent::delete(); }
/** * Deletes a gallery all * the associated images. * * @return bool */ public function delete() { // Delete the gallery images $this->images()->delete(); // Delete the gallery return parent::delete(); }
public function delete() { if (!parent::delete()) { return; } return $this->instances()->delete(); }
public function delete(Model $model) : bool { $deleted = $model->delete(); if ($deleted) { app('cache')->flush(); } return $deleted; }
/** * @inheritdoc */ public function delete() { $file = $this->getLogFilePath(); if (is_file($file)) { unlink($file); } return parent::delete(); }
public function delete() { $this->tags()->detach(); $this->categorys()->detach(); $this->images()->delete(); $this->comments()->delete(); Model::delete(); }
public function delete() { \File::delete([$this->path, $this->thumbnail_path]); // File::delete($this->path); // File::delete($this->thumnail_path); parent::delete(); // TODO: Change the autogenerated stub }
/** * Make sure we cleanup when a key is deleted * * @return bool|null * @throws \Exception */ public function delete() { // Cleanup the info $this->info()->delete(); // Cleanup the characters this key had $this->characters()->delete(); return parent::delete(); }
/** * {@inheritDoc} */ public function delete() { $isSoftDeleted = array_key_exists('Illuminate\\Database\\Eloquent\\SoftDeletes', class_uses($this)); if ($this->exists && !$isSoftDeleted) { $this->users()->detach(); } return parent::delete(); }
public function delete() { // Remove all relationships $this->coupons()->detach(); $this->bundles()->detach(); $this->orders()->detach(); return parent::delete(); }
public function delete() { $stockClass = config('mojito.stockClass', 'Stock'); foreach ($stockClass::byWarehouse($this->id)->get() as $object) { $object->delete(); } return parent::delete(); }
public function delete() { //删除此文章下的所有评论 foreach ($this->comments() as $comment) { $comment->delete(); } //删除自身 parent::delete(); }
public function delete() { $id = $this->id; $deleted = parent::delete(); if ($deleted) { event(new CUD($this->user, 'delete', $this, ['id' => $id])); } return $deleted; }
public function delete() { // Remove all relationships $this->pricelists()->detach(); $this->products()->detach(); $this->categories()->detach(); $this->users()->detach(); return parent::delete(); }
/** * 复写系统方法 * @return bool|null */ public function delete() { # 异常化编程 if ($deleted = parent::delete()) { return $deleted; } $e = get_called_class() . 'DeleteFailException'; throw new $e(); }