Skip to content

Commit

Permalink
Do not use IoC to call remove events.
Browse files Browse the repository at this point in the history
  • Loading branch information
yajra committed Dec 16, 2017
1 parent 3b2018a commit f6acb7c
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/DataTablesEditor.php
Expand Up @@ -209,15 +209,15 @@ abstract public function getEditRules(Model $model);
*/
public function remove(Request $request)
{
$model = $this->resolveModel();
$connection = $model->getConnection();
$instance = $this->resolveModel();
$connection = $instance->getConnection();
$affected = [];
$errors = [];

$connection->beginTransaction();
foreach ($request->get('data') as $key => $datum) {
$instance = $model->newQuery()->find($key);
$validator = $this->getValidationFactory()->make($datum, $this->getRemoveRules($instance));
foreach ($request->get('data') as $key => $data) {
$model = $instance->newQuery()->find($key);
$validator = $this->getValidationFactory()->make($data, $this->getRemoveRules($model));
if ($validator->fails()) {
foreach ($this->formatErrors($validator) as $error) {
$errors[] = $error;
Expand All @@ -227,16 +227,16 @@ public function remove(Request $request)
}

if (method_exists($this, 'deleting')) {
app()->call([$this, 'deleting'], ['model' => $instance]);
$this->deleting($model, $data);
}

$instance->delete();
$model->delete();

if (method_exists($this, 'deleted')) {
app()->call([$this, 'deleted'], ['model' => $instance]);
$this->deleted($model, $data);
}

$affected[] = $instance;
$affected[] = $model;
}

if (! $errors) {
Expand Down

0 comments on commit f6acb7c

Please sign in to comment.