當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。