delete() public method

Delete the model from the database.
public delete ( ) : boolean | null
return boolean | null
Example #1
1
 /**
  * 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();
 }
Example #3
0
 /**
  * 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();
 }
Example #4
0
 public function delete()
 {
     foreach ($this->projects as $project) {
         $project->delete();
     }
     parent::delete();
 }
Example #5
0
 public function delete()
 {
     foreach (VendorItemPivot::byVendor($this->id)->get() as $object) {
         $object->delete();
     }
     return parent::delete();
 }
Example #6
0
 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();
 }
Example #7
0
 /**
  * {@inheritdoc}
  */
 public function delete()
 {
     if ($this->exists) {
         $this->tagged()->delete();
     }
     return parent::delete();
 }
Example #8
0
 /**
  * Delete Questions before deleting Group itself.
  *
  * @return bool|null
  * @throws \Exception
  */
 public function delete()
 {
     $this->questions->each(function ($question) {
         $question->delete();
     });
     return parent::delete();
 }
Example #9
0
 public function delete()
 {
     foreach ($this->photos as $photo) {
         File::delete($photo->path);
     }
     parent::delete();
 }
Example #10
0
 /**
  * Delete Groups before deleting Section itself.
  *
  * @return bool|null
  * @throws \Exception
  */
 public function delete()
 {
     $this->groups->each(function ($group) {
         $group->delete();
     });
     return parent::delete();
 }
Example #11
0
 public function delete()
 {
     $this->is()->delete();
     $this->photos()->delete();
     // δεν είμαι σίγουρος αν διαγράφει ΟΛΕΣ τις φωτογραφίες
     parent::delete();
 }
Example #12
0
 /**
  * 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();
 }
Example #13
0
 /**
  * 删除资源
  *
  * @param \Illuminate\Database\Eloquent\Model $model
  *
  * @return mixed
  * @throws \Exception
  */
 public function destroy(Model $model)
 {
     if ($model->delete()) {
         return $this->success('删除成功');
     }
     return $this->error('删除失败');
 }
Example #14
0
 /**
  * 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;
 }
Example #16
0
 public function delete()
 {
     if ($this->featured_image != '') {
         $this->deleteImage($this->featured_image);
     }
     parent::delete();
 }
Example #17
0
 /**
  * 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();
 }
Example #18
0
 public function delete()
 {
     if (!parent::delete()) {
         return;
     }
     return $this->instances()->delete();
 }
Example #19
0
 public function delete(Model $model) : bool
 {
     $deleted = $model->delete();
     if ($deleted) {
         app('cache')->flush();
     }
     return $deleted;
 }
Example #20
0
 /**
  * @inheritdoc
  */
 public function delete()
 {
     $file = $this->getLogFilePath();
     if (is_file($file)) {
         unlink($file);
     }
     return parent::delete();
 }
Example #21
0
 public function delete()
 {
     $this->tags()->detach();
     $this->categorys()->detach();
     $this->images()->delete();
     $this->comments()->delete();
     Model::delete();
 }
Example #22
0
 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
 }
Example #23
0
 /**
  * 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();
 }
Example #24
0
 /**
  * {@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();
 }
Example #25
0
 public function delete()
 {
     // Remove all relationships
     $this->coupons()->detach();
     $this->bundles()->detach();
     $this->orders()->detach();
     return parent::delete();
 }
Example #26
0
 public function delete()
 {
     $stockClass = config('mojito.stockClass', 'Stock');
     foreach ($stockClass::byWarehouse($this->id)->get() as $object) {
         $object->delete();
     }
     return parent::delete();
 }
Example #27
0
 public function delete()
 {
     //删除此文章下的所有评论
     foreach ($this->comments() as $comment) {
         $comment->delete();
     }
     //删除自身
     parent::delete();
 }
Example #28
0
 public function delete()
 {
     $id = $this->id;
     $deleted = parent::delete();
     if ($deleted) {
         event(new CUD($this->user, 'delete', $this, ['id' => $id]));
     }
     return $deleted;
 }
Example #29
0
 public function delete()
 {
     // Remove all relationships
     $this->pricelists()->detach();
     $this->products()->detach();
     $this->categories()->detach();
     $this->users()->detach();
     return parent::delete();
 }
Example #30
0
 /**
  * 复写系统方法
  * @return bool|null
  */
 public function delete()
 {
     # 异常化编程
     if ($deleted = parent::delete()) {
         return $deleted;
     }
     $e = get_called_class() . 'DeleteFailException';
     throw new $e();
 }