@@ -126,7 +126,7 @@ |
||
126 | 126 | * @param string|null $characteristicIdCroppingSystem |
127 | 127 | * @return Paginator |
128 | 128 | * |
129 | - */ |
|
129 | + */ |
|
130 | 130 | public function getFollowersPage(int $pageId, string $type = 'follow', ?string $departmentNumber = null, ?string $characteristicId = null, ?string $characteristicIdCroppingSystem = null): Paginator |
131 | 131 | { |
132 | 132 | return InteractionModel::query() |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | ->where('page_id', $interaction->pageId()) |
26 | 26 | ->first(); |
27 | 27 | |
28 | - if($interactionModel === null) { |
|
28 | + if ($interactionModel === null) { |
|
29 | 29 | $interactionModel = new InteractionModel(); |
30 | 30 | $interactionModel->{$canInteract->key()} = isset($user->id) ? $user->id : $canInteract->identifier(); |
31 | 31 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | |
38 | 38 | public function getByInteractUser(CanInteract $canInteract, int $pageId): ?Interaction |
39 | 39 | { |
40 | - if($canInteract->key() == 'user_id') { |
|
40 | + if ($canInteract->key() == 'user_id') { |
|
41 | 41 | $user = User::query()->where('uuid', $canInteract->identifier())->first(); |
42 | 42 | } |
43 | 43 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | ->where('page_id', $pageId) |
47 | 47 | ->first(); |
48 | 48 | |
49 | - if(!isset($interactionModel)){ |
|
49 | + if (!isset($interactionModel)) { |
|
50 | 50 | return null; |
51 | 51 | } |
52 | 52 | |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | ->orderBy('updated_at', 'desc') |
83 | 83 | ->get(); |
84 | 84 | |
85 | - foreach($interactionsModel as $interaction) { |
|
85 | + foreach ($interactionsModel as $interaction) { |
|
86 | 86 | $page = PageModel::query()->where('page_id', $interaction->page_id)->first(); |
87 | - if(!isset($page)){ |
|
87 | + if (!isset($page)) { |
|
88 | 88 | continue; |
89 | 89 | } |
90 | 90 | $applause = InteractionModel::query()->where('page_id', $interaction->page_id)->where('applause', true)->count(); |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | ->where('user_id', $user->id) |
108 | 108 | ->where('done', true) |
109 | 109 | ->get(); |
110 | - foreach ($records as $record){ |
|
110 | + foreach ($records as $record) { |
|
111 | 111 | $practises[] = new PractiseVo( |
112 | 112 | $record->page_id, |
113 | 113 | $record->page->title ?? '', |
@@ -131,18 +131,18 @@ discard block |
||
131 | 131 | { |
132 | 132 | return InteractionModel::query() |
133 | 133 | ->with('user.context') |
134 | - ->where(function ($query) use ($type){ |
|
135 | - $query->when($type === 'follow', function ($query) { |
|
134 | + ->where(function($query) use ($type){ |
|
135 | + $query->when($type === 'follow', function($query) { |
|
136 | 136 | $query->where('follow', true); |
137 | 137 | $query->orWhere('done', true); |
138 | 138 | }) |
139 | - ->when($type === 'do', function ($query) { |
|
139 | + ->when($type === 'do', function($query) { |
|
140 | 140 | $query->where('done', true); |
141 | 141 | }); |
142 | 142 | }) |
143 | - ->when($characteristicId !== null, function ($query) use($characteristicId) { |
|
143 | + ->when($characteristicId !== null, function($query) use($characteristicId) { |
|
144 | 144 | $characteristic = CharacteristicsModel::query()->where('uuid', $characteristicId)->first(); |
145 | - if(!isset($characteristic)){ |
|
145 | + if (!isset($characteristic)) { |
|
146 | 146 | return; |
147 | 147 | } |
148 | 148 | $query->whereRaw( |
@@ -150,9 +150,9 @@ discard block |
||
150 | 150 | $characteristic->id |
151 | 151 | ); |
152 | 152 | }) |
153 | - ->when($characteristicIdCroppingSystem !== null, function ($query) use($characteristicIdCroppingSystem) { |
|
153 | + ->when($characteristicIdCroppingSystem !== null, function($query) use($characteristicIdCroppingSystem) { |
|
154 | 154 | $characteristic = CharacteristicsModel::query()->where('uuid', $characteristicIdCroppingSystem)->first(); |
155 | - if(!isset($characteristic)){ |
|
155 | + if (!isset($characteristic)) { |
|
156 | 156 | return; |
157 | 157 | } |
158 | 158 | $query->whereRaw( |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | $characteristic->id |
161 | 161 | ); |
162 | 162 | }) |
163 | - ->when($departmentNumber !== null, function ($query) use($departmentNumber) { |
|
163 | + ->when($departmentNumber !== null, function($query) use($departmentNumber) { |
|
164 | 164 | $query |
165 | 165 | ->join('users', 'users.id', 'interactions.user_id') |
166 | 166 | ->join('contexts', 'users.context_id', 'contexts.id') |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | ->whereNotNull('interactions.user_id') |
171 | 171 | ->orderBy('interactions.updated_at', 'desc') |
172 | 172 | ->paginate() |
173 | - ->through(function ($item){ |
|
173 | + ->through(function($item) { |
|
174 | 174 | return $item->user->context->toDto($item->user->uuid, $item->start_done_at ? $item->start_done_at->format('Y-m-d') : $item->done); |
175 | 175 | }) |
176 | 176 | ; |
@@ -14,11 +14,11 @@ discard block |
||
14 | 14 | |
15 | 15 | class ContextRepositorySql implements ContextRepository |
16 | 16 | { |
17 | - public function getByUser(string $userId):?Context |
|
17 | + public function getByUser(string $userId): ?Context |
|
18 | 18 | { |
19 | 19 | $user = User::where('uuid', $userId)->first(); |
20 | 20 | $context = DB::table('contexts')->where('id', $user->context_id)->first(); |
21 | - if($context == null){ |
|
21 | + if ($context == null) { |
|
22 | 22 | return null; |
23 | 23 | } |
24 | 24 | return new Context( |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | $user = User::where('uuid', $userId)->first(); |
38 | 38 | |
39 | 39 | $farmings = $contextData->get('farmings'); |
40 | - foreach($farmings as $farming){ |
|
41 | - $characteristic = CharacteristicsModel::where('uuid', (string)$farming)->first(); |
|
40 | + foreach ($farmings as $farming) { |
|
41 | + $characteristic = CharacteristicsModel::where('uuid', (string) $farming)->first(); |
|
42 | 42 | $user->characteristics()->save($characteristic); |
43 | 43 | } |
44 | 44 | |
@@ -51,20 +51,20 @@ discard block |
||
51 | 51 | public function getByUserDto(string $userId): ?ContextDto |
52 | 52 | { |
53 | 53 | $user = User::where('uuid', $userId)->first(); |
54 | - if($user == null){ |
|
54 | + if ($user == null) { |
|
55 | 55 | return null; |
56 | 56 | } |
57 | 57 | $context = ContextModel::find($user->context_id); |
58 | - if($context == null){ |
|
58 | + if ($context == null) { |
|
59 | 59 | return null; |
60 | 60 | } |
61 | - $characteristics = $user->characteristics()->get()->transform(function(CharacteristicsModel $item){ |
|
61 | + $characteristics = $user->characteristics()->get()->transform(function(CharacteristicsModel $item) { |
|
62 | 62 | return $item->toDto(); |
63 | 63 | }); |
64 | 64 | |
65 | 65 | $numberDepartment = $context->department_number; |
66 | 66 | $characteristicDepartment = CharacteristicsModel::query()->where('code', $numberDepartment)->first(); |
67 | - if(isset($characteristicDepartment)){ |
|
67 | + if (isset($characteristicDepartment)) { |
|
68 | 68 | $characteristics->push($characteristicDepartment->toDto()); |
69 | 69 | } |
70 | 70 | |
@@ -85,12 +85,12 @@ discard block |
||
85 | 85 | public function update(Context $context, string $userId) |
86 | 86 | { |
87 | 87 | $user = User::where('uuid', $userId)->first(); |
88 | - if($user === null){ |
|
88 | + if ($user === null) { |
|
89 | 89 | return null; |
90 | 90 | } |
91 | 91 | |
92 | 92 | $contextModel = ContextModel::where('uuid', $context->id())->first(); |
93 | - if($contextModel === null){ |
|
93 | + if ($contextModel === null) { |
|
94 | 94 | return null; |
95 | 95 | } |
96 | 96 | $contextData = collect($context->toArray()); |
@@ -98,9 +98,9 @@ discard block |
||
98 | 98 | |
99 | 99 | $farmings = $contextData->get('farmings'); |
100 | 100 | $characteristics = []; |
101 | - foreach($farmings as $farming){ |
|
102 | - $characteristicModel = CharacteristicsModel::where('uuid', (string)$farming)->first(); |
|
103 | - if(isset($characteristicModel)) { |
|
101 | + foreach ($farmings as $farming) { |
|
102 | + $characteristicModel = CharacteristicsModel::where('uuid', (string) $farming)->first(); |
|
103 | + if (isset($characteristicModel)) { |
|
104 | 104 | $characteristics[] = $characteristicModel->id; |
105 | 105 | } |
106 | 106 | } |
@@ -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; |