本文整理汇总了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();
}
示例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);
}
示例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);
}
示例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;
}
示例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']);
}
示例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;
}
示例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;
}
}
示例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);
}
}
示例9: destroy
public function destroy(array $ids)
{
return $this->model->destroy($ids);
}
示例10: deleteMultipleById
/**
* Delete multiple records
*
* @param array $ids
*
* @return int
*/
public function deleteMultipleById(array $ids)
{
return $this->model->destroy($ids);
}
示例11: destroy
/**
* Destroy an existing record
* @param $id
* @return mixed
*/
public function destroy($id)
{
return $this->model->destroy($id);
}
示例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);
}
示例13: delete
/**
* @param $id
* @return integer
*/
public function delete($id)
{
$result = $this->model->destroy($id);
$this->refresh();
return $result;
}
示例14: delete
/**
* Delete multiple entity in repository.
*
* @param $id
*
* @return int
*/
public function delete($id)
{
$this->makeModel();
return $this->model->destroy($id);
}
示例15: destroy
public function destroy($id)
{
$this->roleModel->destroy($id);
$this->setStatusMessage(trans('aliukevicius/laravelRbac::lang.role.messageDeleted'));
return \Redirect::to($this->getRoleUrl('index'));
}