當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Model::destroy方法代碼示例

本文整理匯總了PHP中Illuminate\Database\Eloquent\Model::destroy方法的典型用法代碼示例。如果您正苦於以下問題:PHP Model::destroy方法的具體用法?PHP Model::destroy怎麽用?PHP Model::destroy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Database\Eloquent\Model的用法示例。


在下文中一共展示了Model::destroy方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: delete

 /**
  * Delete a entity in modal by id.
  *
  * @param $id
  *
  * @return int
  */
 public function delete($id)
 {
     $id = $this->decrypt($id);
     $this->model->destroy($id);
     $this->resetModel();
     return $model->delete();
 }
開發者ID:LavaliteCms,項目名稱:Example,代碼行數:14,代碼來源:BaseRepository.php

示例2: delete

 /**
  * Deletes a record, $id can be a model instance.
  *
  * @param $id
  * @return mixed
  */
 public function delete($id)
 {
     if ($id instanceof Model) {
         return $id->delete();
     }
     return $this->model->destroy($id);
 }
開發者ID:logaretm,項目名稱:depo,代碼行數:13,代碼來源:RepositoryBase.php

示例3: getDelete

 /**
  * Delete the entry from the fbsql_database(link_identifier)
  */
 public function getDelete($id, Redirector $redirect)
 {
     if ($this->model->destroy($id)) {
         return $redirect->back()->withSuccess('Item has been deleted successfully');
     }
     abort(500);
 }
開發者ID:dakshhmehta,項目名稱:laravel-starter-kit,代碼行數:10,代碼來源:CRUDController.php

示例4: delete

 /**
  * Delete models from the database by their primary key.
  *
  * @param  mixed $ids
  * @return bool
  */
 public function delete($ids)
 {
     $ids = $this->convertToModelCollection($ids);
     $results = $this->model->destroy($this->hookDelete($ids)->modelKeys());
     $this->reset();
     return $results;
 }
開發者ID:propaganistas,項目名稱:laravel-repository,代碼行數:13,代碼來源:Repository.php

示例5: destroyModel

 /**
  * @author WN
  * @param Model $model
  * @param int $id
  * @param string $modelName
  * @param string $redirect
  * @return \Illuminate\Http\RedirectResponse
  * @throws RedirectException
  */
 protected function destroyModel(Model $model, $id, $modelName, $redirect)
 {
     try {
         $model->findOrFail($id);
         $model->destroy($id);
     } catch (ModelNotFoundException $e) {
         $this->logError('Deletion of this record did not complete successfully' . $e->getMessage());
         throw (new RedirectException())->setTarget($redirect)->setError('Deletion of this record did not complete successfully');
     }
     return redirect($redirect)->with('messages', ['success' => ucwords($modelName) . ' was successfully deleted']);
 }
開發者ID:paybreak,項目名稱:basket,代碼行數:20,代碼來源:ModelTrait.php

示例6: delete

 /**
  * @param mixed $id
  * @return int
  */
 public function delete($id = null)
 {
     $model = null;
     if (is_array($id)) {
         $model = $this->model->destroy($id);
     } elseif (!is_null($id)) {
         $model = $this->find($id)->delete();
     } elseif ($this->model instanceof Builder) {
         $model = $this->first()->delete();
     }
     $this->cleanRepository();
     return $model;
 }
開發者ID:guilhermegonzaga,項目名稱:repository,代碼行數:17,代碼來源:Repository.php

示例7: delete

 /**
  * Delete a record by id of record or entity
  * @param $entity
  * @return null
  */
 public function delete($entity)
 {
     try {
         if (is_numeric($entity)) {
             $this->model->destroy($entity);
         } else {
             $entity = $this->findOrFail($entity);
             $entity->delete();
         }
         return true;
     } catch (\Exception $e) {
         return false;
     }
 }
開發者ID:Burris19,項目名稱:ReposityLaravel,代碼行數:19,代碼來源:Repository.php

示例8: delete

 /**
  * Delete a model by the following:
  *     $model               itself when a model is given
  *     [$model[,...]]       array or collection of models
  *     $id                  id of the model
  *     [id1[, id2, ...]]    array of ids.
  *
  * @param  mixed    $model
  * @return bool|int Boolean when model is deleted or the number of models deleted
  */
 public function delete($model)
 {
     // First use-case, itself when a model is given
     if ($model instanceof $this->model) {
         return $model->delete();
     }
     // Second use-case, array or collection of models
     $models = $model;
     if (is_array($models) && head($models) instanceof $this->model) {
         $models = $this->model->newCollection($models);
     }
     if ($models instanceof Collection) {
         $model = $models->pluck('id');
         // Pass ids to $model to be deleted below on third and fourth use-case
     }
     // Third and fourth use-case, id or array of ids
     $ids = $model;
     if (is_int($model)) {
         $ids = [$ids];
     }
     if (!empty($ids)) {
         return $this->model->destroy($ids);
     }
 }
開發者ID:sedp-mis,項目名稱:base-repository,代碼行數:34,代碼來源:BaseRepositoryEloquent.php

示例9: destroy

 public function destroy(array $ids)
 {
     return $this->model->destroy($ids);
 }
開發者ID:mayconbordin,項目名稱:reloquent,代碼行數:4,代碼來源:BaseRepository.php

示例10: deleteMultipleById

 /**
  * Delete multiple records
  *
  * @param array $ids
  *
  * @return int
  */
 public function deleteMultipleById(array $ids)
 {
     return $this->model->destroy($ids);
 }
開發者ID:Okipa,項目名稱:una.app,代碼行數:11,代碼來源:BaseRepository.php

示例11: destroy

 /**
  * Destroy an existing record
  * @param $id
  * @return mixed
  */
 public function destroy($id)
 {
     return $this->model->destroy($id);
 }
開發者ID:perezatanaciod,項目名稱:LaravelRepositories,代碼行數:9,代碼來源:Repository.php

示例12: destroy

 /**
  * Destroys a particular or set of models.
  *
  * Arguments are either a single ID or an array of IDs
  * @param int[]|string[]|int|string $ids
  * @return int The number of records deleted
  */
 public function destroy($ids)
 {
     $this->model->destroy($ids);
 }
開發者ID:msivia,項目名稱:Toolbox,代碼行數:11,代碼來源:ActiveRepositoryAbstract.php

示例13: delete

 /**
  * @param $id
  * @return integer
  */
 public function delete($id)
 {
     $result = $this->model->destroy($id);
     $this->refresh();
     return $result;
 }
開發者ID:ablunier,項目名稱:laravel-database,代碼行數:10,代碼來源:Repository.php

示例14: delete

 /**
  * Delete multiple entity in repository.
  *
  * @param $id
  *
  * @return int
  */
 public function delete($id)
 {
     $this->makeModel();
     return $this->model->destroy($id);
 }
開發者ID:sjfinder,項目名稱:repository,代碼行數:12,代碼來源:BaseRepository.php

示例15: destroy

 public function destroy($id)
 {
     $this->roleModel->destroy($id);
     $this->setStatusMessage(trans('aliukevicius/laravelRbac::lang.role.messageDeleted'));
     return \Redirect::to($this->getRoleUrl('index'));
 }
開發者ID:aliukevicius,項目名稱:laravel-rbac,代碼行數:6,代碼來源:RoleController.php


注:本文中的Illuminate\Database\Eloquent\Model::destroy方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。