@@ -25,12 +25,12 @@ |
||
| 25 | 25 | |
| 26 | 26 | public function toDto(?string $userUid = null, $hasDone = false):ContextDto |
| 27 | 27 | { |
| 28 | - $characteristics = $this->user->characteristics()->get()->transform(function(CharacteristicsModel $item){ |
|
| 28 | + $characteristics = $this->user->characteristics()->get()->transform(function(CharacteristicsModel $item) { |
|
| 29 | 29 | return $item->toDto(); |
| 30 | 30 | }); |
| 31 | 31 | $characteristicDepartment = CharacteristicsModel::query()->where('code', $this->department_number)->first(); |
| 32 | 32 | |
| 33 | - if(isset($characteristicDepartment)){ |
|
| 33 | + if (isset($characteristicDepartment)) { |
|
| 34 | 34 | $characteristics->push($characteristicDepartment->toDto()); |
| 35 | 35 | } |
| 36 | 36 | |
@@ -38,7 +38,7 @@ |
||
| 38 | 38 | $this->postalCode = $postalCode; |
| 39 | 39 | $this->department = $departmentNumber; |
| 40 | 40 | $this->characteristics = $characteristics; |
| 41 | - foreach($this->characteristics as $characteristic){ |
|
| 41 | + foreach ($this->characteristics as $characteristic) { |
|
| 42 | 42 | $this->characteristicsByType[$characteristic->type()][] = $characteristic; |
| 43 | 43 | } |
| 44 | 44 | $this->description = $description; |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | class ContextRepositorySql implements ContextRepository |
| 15 | 15 | { |
| 16 | - public function getByUser(string $userId):?Context |
|
| 16 | + public function getByUser(string $userId): ?Context |
|
| 17 | 17 | { |
| 18 | 18 | $user = User::where('uuid', $userId)->first(); |
| 19 | 19 | return $user->context !== null ? $user->context->toDomain() : null; |
@@ -25,8 +25,8 @@ discard block |
||
| 25 | 25 | $user = User::where('uuid', $userId)->first(); |
| 26 | 26 | |
| 27 | 27 | $farmings = $contextData->get('farmings'); |
| 28 | - foreach($farmings as $farming){ |
|
| 29 | - $characteristic = CharacteristicsModel::where('uuid', (string)$farming)->first(); |
|
| 28 | + foreach ($farmings as $farming) { |
|
| 29 | + $characteristic = CharacteristicsModel::where('uuid', (string) $farming)->first(); |
|
| 30 | 30 | $user->characteristics()->save($characteristic); |
| 31 | 31 | } |
| 32 | 32 | |
@@ -39,20 +39,20 @@ discard block |
||
| 39 | 39 | public function getByUserDto(string $userId): ?ContextDto |
| 40 | 40 | { |
| 41 | 41 | $user = User::where('uuid', $userId)->first(); |
| 42 | - if($user == null){ |
|
| 42 | + if ($user == null) { |
|
| 43 | 43 | return null; |
| 44 | 44 | } |
| 45 | 45 | $context = ContextModel::find($user->context_id); |
| 46 | - if($context == null){ |
|
| 46 | + if ($context == null) { |
|
| 47 | 47 | return null; |
| 48 | 48 | } |
| 49 | - $characteristics = $user->characteristics()->get()->transform(function(CharacteristicsModel $item){ |
|
| 49 | + $characteristics = $user->characteristics()->get()->transform(function(CharacteristicsModel $item) { |
|
| 50 | 50 | return $item->toDto(); |
| 51 | 51 | }); |
| 52 | 52 | |
| 53 | 53 | $numberDepartment = $context->department_number; |
| 54 | 54 | $characteristicDepartment = CharacteristicsModel::query()->where('code', $numberDepartment)->first(); |
| 55 | - if(isset($characteristicDepartment)){ |
|
| 55 | + if (isset($characteristicDepartment)) { |
|
| 56 | 56 | $characteristics->push($characteristicDepartment->toDto()); |
| 57 | 57 | } |
| 58 | 58 | |
@@ -73,12 +73,12 @@ discard block |
||
| 73 | 73 | public function update(Context $context, string $userId) |
| 74 | 74 | { |
| 75 | 75 | $user = User::where('uuid', $userId)->first(); |
| 76 | - if($user === null){ |
|
| 76 | + if ($user === null) { |
|
| 77 | 77 | return null; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | $contextModel = ContextModel::where('uuid', $context->id())->first(); |
| 81 | - if($contextModel === null){ |
|
| 81 | + if ($contextModel === null) { |
|
| 82 | 82 | return null; |
| 83 | 83 | } |
| 84 | 84 | $contextData = collect($context->toArray()); |
@@ -86,9 +86,9 @@ discard block |
||
| 86 | 86 | |
| 87 | 87 | $farmings = $contextData->get('farmings'); |
| 88 | 88 | $characteristics = []; |
| 89 | - foreach($farmings as $farming){ |
|
| 90 | - $characteristicModel = CharacteristicsModel::where('uuid', (string)$farming)->first(); |
|
| 91 | - if(isset($characteristicModel)) { |
|
| 89 | + foreach ($farmings as $farming) { |
|
| 90 | + $characteristicModel = CharacteristicsModel::where('uuid', (string) $farming)->first(); |
|
| 91 | + if (isset($characteristicModel)) { |
|
| 92 | 92 | $characteristics[] = $characteristicModel->id; |
| 93 | 93 | } |
| 94 | 94 | } |
@@ -30,12 +30,12 @@ discard block |
||
| 30 | 30 | return $list->toArray(); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - public function getByPageId(int $pageId):?Characteristic |
|
| 33 | + public function getByPageId(int $pageId): ?Characteristic |
|
| 34 | 34 | { |
| 35 | 35 | $c = CharacteristicsModel::query() |
| 36 | 36 | ->where('page_id', $pageId) |
| 37 | 37 | ->first(); |
| 38 | - if(!isset($c)){ |
|
| 38 | + if (!isset($c)) { |
|
| 39 | 39 | return null; |
| 40 | 40 | } |
| 41 | 41 | return $c->toDomain(); |
@@ -61,14 +61,14 @@ discard block |
||
| 61 | 61 | public function getBy(array $conditions): ?Characteristic |
| 62 | 62 | { |
| 63 | 63 | $characteristicModel = CharacteristicsModel::query() |
| 64 | - ->when(isset($conditions['type']), function ($query) use($conditions){ |
|
| 64 | + ->when(isset($conditions['type']), function($query) use($conditions){ |
|
| 65 | 65 | $query->where('type', $conditions['type']); |
| 66 | 66 | }) |
| 67 | - ->when(isset($conditions['title']), function ($query) use($conditions){ |
|
| 67 | + ->when(isset($conditions['title']), function($query) use($conditions){ |
|
| 68 | 68 | $query->where('code', $conditions['title']); |
| 69 | 69 | }) |
| 70 | 70 | ->first(); |
| 71 | - if(!isset($characteristicModel)){ |
|
| 71 | + if (!isset($characteristicModel)) { |
|
| 72 | 72 | return null; |
| 73 | 73 | } |
| 74 | 74 | return $characteristicModel->toDomain(); |
@@ -78,13 +78,13 @@ discard block |
||
| 78 | 78 | { |
| 79 | 79 | $characteristicModel = CharacteristicsModel::query() |
| 80 | 80 | ->where('type', $type) |
| 81 | - ->where('pretty_page_label','LIKE', '%'.$search.'%') |
|
| 81 | + ->where('pretty_page_label', 'LIKE', '%'.$search.'%') |
|
| 82 | 82 | ->get(); |
| 83 | 83 | |
| 84 | - if(!isset($characteristicModel)){ |
|
| 84 | + if (!isset($characteristicModel)) { |
|
| 85 | 85 | return []; |
| 86 | 86 | } |
| 87 | - foreach ($characteristicModel as $characteristic){ |
|
| 87 | + foreach ($characteristicModel as $characteristic) { |
|
| 88 | 88 | $characteristics[] = $characteristic->toArray(); |
| 89 | 89 | } |
| 90 | 90 | return $characteristics ?? []; |