destroy() public static method

Destroy the models for the given IDs.
public static destroy ( array | integer $ids ) : integer
$ids array | integer
return integer
Example #1
0
 /**
  * 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();
 }
Example #2
0
 /**
  * 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);
 }
 /**
  * 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);
 }
 /**
  * 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;
 }
Example #5
0
 /**
  * @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']);
 }
 /**
  * @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;
 }
Example #7
0
 /**
  * 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;
     }
 }
 /**
  * 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);
     }
 }
 public function destroy(array $ids)
 {
     return $this->model->destroy($ids);
 }
Example #10
0
 /**
  * Delete multiple records
  *
  * @param array $ids
  *
  * @return int
  */
 public function deleteMultipleById(array $ids)
 {
     return $this->model->destroy($ids);
 }
 /**
  * Destroy an existing record
  * @param $id
  * @return mixed
  */
 public function destroy($id)
 {
     return $this->model->destroy($id);
 }
 /**
  * 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);
 }
Example #13
0
 /**
  * @param $id
  * @return integer
  */
 public function delete($id)
 {
     $result = $this->model->destroy($id);
     $this->refresh();
     return $result;
 }
Example #14
0
 /**
  * Delete multiple entity in repository.
  *
  * @param $id
  *
  * @return int
  */
 public function delete($id)
 {
     $this->makeModel();
     return $this->model->destroy($id);
 }
 public function destroy($id)
 {
     $this->roleModel->destroy($id);
     $this->setStatusMessage(trans('aliukevicius/laravelRbac::lang.role.messageDeleted'));
     return \Redirect::to($this->getRoleUrl('index'));
 }
 /**
  * @param $id
  * @return mixed
  */
 public function delete($id)
 {
     $this->model->destroy($id);
 }