当前位置: 首页>>代码示例>>PHP>>正文


PHP Model::delete方法代码示例

本文整理汇总了PHP中Illuminate\Database\Eloquent\Model::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::delete方法的具体用法?PHP Model::delete怎么用?PHP Model::delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Database\Eloquent\Model的用法示例。


在下文中一共展示了Model::delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: deleteThe

 /**
  * 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();
 }
开发者ID:BlazOrazem,项目名称:laravel-basis,代码行数:16,代码来源:BaseController.php

示例2: delete

 /**
  * 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();
 }
开发者ID:bjrnblm,项目名称:blender,代码行数:16,代码来源:UserDbRepository.php

示例3: delete

 public function delete()
 {
     foreach (VendorItemPivot::byVendor($this->id)->get() as $object) {
         $object->delete();
     }
     return parent::delete();
 }
开发者ID:badchoice,项目名称:mojito,代码行数:7,代码来源:Vendor.php

示例4: delete

 public function delete()
 {
     foreach ($this->projects as $project) {
         $project->delete();
     }
     parent::delete();
 }
开发者ID:ixudra,项目名称:portfolio,代码行数:7,代码来源:Customer.php

示例5: remove

 /**
  * 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);
     }
 }
开发者ID:jBOKA,项目名称:library,代码行数:29,代码来源:MorphOneOrMany.php

示例6: 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();
 }
开发者ID:redooor,项目名称:redminportal,代码行数:25,代码来源:Module.php

示例7: delete

 /**
  * {@inheritdoc}
  */
 public function delete()
 {
     if ($this->exists) {
         $this->tagged()->delete();
     }
     return parent::delete();
 }
开发者ID:cartalyst,项目名称:tags,代码行数:10,代码来源:IlluminateTag.php

示例8: 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();
 }
开发者ID:metricloop,项目名称:interrogator,代码行数:13,代码来源:Group.php

示例9: delete

 public function delete()
 {
     foreach ($this->photos as $photo) {
         File::delete($photo->path);
     }
     parent::delete();
 }
开发者ID:myleshyson,项目名称:ivgainesville,代码行数:7,代码来源:Article.php

示例10: 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();
 }
开发者ID:metricloop,项目名称:interrogator,代码行数:13,代码来源:Section.php

示例11: delete

 public function delete()
 {
     $this->is()->delete();
     $this->photos()->delete();
     // δεν είμαι σίγουρος αν διαγράφει ΟΛΕΣ τις φωτογραφίες
     parent::delete();
 }
开发者ID:nicsmyrn,项目名称:library,代码行数:7,代码来源:Product.php

示例12: 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();
 }
开发者ID:JackFrankWen,项目名称:Laravel,代码行数:10,代码来源:Rates_Cat.php

示例13: destroy

 /**
  * 删除资源
  *
  * @param \Illuminate\Database\Eloquent\Model $model
  *
  * @return mixed
  * @throws \Exception
  */
 public function destroy(Model $model)
 {
     if ($model->delete()) {
         return $this->success('删除成功');
     }
     return $this->error('删除失败');
 }
开发者ID:netxinyi,项目名称:meigui,代码行数:15,代码来源:ResourceTrait.php

示例14: delete

 /**
  * 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();
 }
开发者ID:jclyons52,项目名称:mycourse-rocks,代码行数:13,代码来源:Post.php

示例15: delete

 /**
  * Delete an existing model.
  *
  * @throws Exception
  * @return mixed
  */
 public function delete()
 {
     $this->beforeDelete();
     $return = parent::delete();
     $this->afterDelete($return);
     return $return;
 }
开发者ID:christiannwamba,项目名称:laravel-site,代码行数:13,代码来源:BaseModel.php


注:本文中的Illuminate\Database\Eloquent\Model::delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。