From dc151e918171bcf0564dc012d7e4132abcc17d65 Mon Sep 17 00:00:00 2001 From: dpankratov Date: Thu, 22 Aug 2019 11:00:46 +0600 Subject: [PATCH] #-: - fixed bug with updateMany --- src/Traits/EntityControlTrait.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Traits/EntityControlTrait.php b/src/Traits/EntityControlTrait.php index 9c847c5c..a5bbb369 100755 --- a/src/Traits/EntityControlTrait.php +++ b/src/Traits/EntityControlTrait.php @@ -2,11 +2,11 @@ namespace RonasIT\Support\Traits; +use Illuminate\Support\Arr; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; use RonasIT\Support\Exceptions\InvalidModelException; use RonasIT\Support\Exceptions\PostValidationException; -use Illuminate\Support\Arr; /** * @property Model model @@ -135,7 +135,7 @@ public function create($data) if (!empty($this->requiredRelations)) { $model->load($this->requiredRelations); } - + $this->afterCreateHook($model, $data); return $model->refresh()->toArray(); @@ -156,8 +156,7 @@ public function updateMany($where, array $data) $entityData = Arr::only($data, $fields); $this - ->getQuery() - ->where($where) + ->getQuery($where) ->update($entityData); return $this->get(array_merge($where, $entityData)); @@ -415,12 +414,12 @@ protected function checkPrimaryKey() throw new InvalidModelException("Model {$modelClass} must have primary key."); } } - + protected function afterUpdateHook($entity, $data) { // implement it yourself if you need it } - + protected function afterCreateHook($entity, $data) { // implement it yourself if you need it