当前位置: 首页>>代码示例>>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;未经允许,请勿转载。