@@ -124,7 +124,7 @@ |
||
124 | 124 | * @param string|null $characteristicIdCroppingSystem |
125 | 125 | * @return Paginator |
126 | 126 | * |
127 | - */ |
|
127 | + */ |
|
128 | 128 | |
129 | 129 | public function getFollowersPage(int $pageId, string $type = 'follow', ?string $departmentNumber = null, ?string $characteristicId = null, ?string $characteristicIdCroppingSystem = null): Paginator |
130 | 130 | { |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | ->where('page_id', $interaction->pageId()) |
27 | 27 | ->first(); |
28 | 28 | |
29 | - if($interactionModel === null) { |
|
29 | + if ($interactionModel === null) { |
|
30 | 30 | $interactionModel = new InteractionModel(); |
31 | 31 | $interactionModel->{$canInteract->key()} = isset($user->id) ? $user->id : $canInteract->identifier(); |
32 | 32 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | |
39 | 39 | public function getByInteractUser(CanInteract $canInteract, int $pageId): ?Interaction |
40 | 40 | { |
41 | - if($canInteract->key() == 'user_id') { |
|
41 | + if ($canInteract->key() == 'user_id') { |
|
42 | 42 | $user = User::query()->where('uuid', $canInteract->identifier())->first(); |
43 | 43 | } |
44 | 44 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | ->where('page_id', $pageId) |
48 | 48 | ->first(); |
49 | 49 | |
50 | - if(!isset($interactionModel)){ |
|
50 | + if (!isset($interactionModel)) { |
|
51 | 51 | return null; |
52 | 52 | } |
53 | 53 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | ->orderBy('updated_at', 'desc') |
84 | 84 | ->get(); |
85 | 85 | |
86 | - foreach($interactionsModel as $interaction) { |
|
86 | + foreach ($interactionsModel as $interaction) { |
|
87 | 87 | $page = PageModel::query()->where('page_id', $interaction->page_id)->first(); |
88 | 88 | $applause = InteractionModel::query()->where('page_id', $interaction->page_id)->where('applause', true)->count(); |
89 | 89 | if ($interaction->follow) { |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | ->where('user_id', $user->id) |
106 | 106 | ->where('done', true) |
107 | 107 | ->get(); |
108 | - foreach ($records as $record){ |
|
108 | + foreach ($records as $record) { |
|
109 | 109 | $practises[] = new PractiseVo( |
110 | 110 | $record->page_id, |
111 | 111 | $record->page->title ?? '', |
@@ -135,18 +135,18 @@ discard block |
||
135 | 135 | |
136 | 136 | return InteractionModel::query() |
137 | 137 | ->with('user.context') |
138 | - ->where(function ($query) use ($type){ |
|
139 | - $query->when($type === 'follow', function ($query) { |
|
138 | + ->where(function($query) use ($type){ |
|
139 | + $query->when($type === 'follow', function($query) { |
|
140 | 140 | $query->where('follow', true); |
141 | 141 | $query->orWhere('done', true); |
142 | 142 | }) |
143 | - ->when($type === 'do', function ($query) { |
|
143 | + ->when($type === 'do', function($query) { |
|
144 | 144 | $query->where('done', true); |
145 | 145 | }); |
146 | 146 | }) |
147 | - ->when($characteristicId !== null, function ($query) use($characteristicId) { |
|
147 | + ->when($characteristicId !== null, function($query) use($characteristicId) { |
|
148 | 148 | $characteristic = CharacteristicsModel::query()->where('uuid', $characteristicId)->first(); |
149 | - if(!isset($characteristic)){ |
|
149 | + if (!isset($characteristic)) { |
|
150 | 150 | return; |
151 | 151 | } |
152 | 152 | $query->whereRaw( |
@@ -154,9 +154,9 @@ discard block |
||
154 | 154 | $characteristic->id |
155 | 155 | ); |
156 | 156 | }) |
157 | - ->when($characteristicIdCroppingSystem !== null, function ($query) use($characteristicIdCroppingSystem) { |
|
157 | + ->when($characteristicIdCroppingSystem !== null, function($query) use($characteristicIdCroppingSystem) { |
|
158 | 158 | $characteristic = CharacteristicsModel::query()->where('uuid', $characteristicIdCroppingSystem)->first(); |
159 | - if(!isset($characteristic)){ |
|
159 | + if (!isset($characteristic)) { |
|
160 | 160 | return; |
161 | 161 | } |
162 | 162 | $query->whereRaw( |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | $characteristic->id |
165 | 165 | ); |
166 | 166 | }) |
167 | - ->when($departmentNumber !== null, function ($query) use($departmentNumber) { |
|
167 | + ->when($departmentNumber !== null, function($query) use($departmentNumber) { |
|
168 | 168 | $query |
169 | 169 | ->join('users', 'users.id', 'interactions.user_id') |
170 | 170 | ->join('contexts', 'users.context_id', 'contexts.id') |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | ->whereNotNull('interactions.user_id') |
175 | 175 | ->orderBy('interactions.updated_at', 'desc') |
176 | 176 | ->paginate() |
177 | - ->through(function ($item){ |
|
177 | + ->through(function($item) { |
|
178 | 178 | return $item->user->context->toDto($item->user->uuid, $item->start_done_at ? $item->start_done_at->format('Y-m-d') : $item->done); |
179 | 179 | }) |
180 | 180 | ; |
@@ -130,8 +130,9 @@ |
||
130 | 130 | { |
131 | 131 | // Handle Corsica differently: |
132 | 132 | if (strtolower($departmentNumber) == '2a' || |
133 | - strtolower($departmentNumber) == '2b') |
|
134 | - $departmentNumber = '20'; |
|
133 | + strtolower($departmentNumber) == '2b') { |
|
134 | + $departmentNumber = '20'; |
|
135 | + } |
|
135 | 136 | |
136 | 137 | return InteractionModel::query() |
137 | 138 | ->with('user.context') |
@@ -23,14 +23,14 @@ |
||
23 | 23 | |
24 | 24 | public function toDto(?string $userUid = null, $hasDone = false):ContextDto |
25 | 25 | { |
26 | - $characteristics = $this->user->characteristics()->get()->transform(function(CharacteristicsModel $item){ |
|
26 | + $characteristics = $this->user->characteristics()->get()->transform(function(CharacteristicsModel $item) { |
|
27 | 27 | return $item->toDto(); |
28 | 28 | }); |
29 | 29 | |
30 | 30 | $numberDepartment = (new PostalCode($this->postal_code))->department(); |
31 | 31 | $characteristicDepartment = CharacteristicsModel::query()->where('code', $numberDepartment)->first(); |
32 | 32 | |
33 | - if(isset($characteristicDepartment)){ |
|
33 | + if (isset($characteristicDepartment)) { |
|
34 | 34 | $characteristics->push($characteristicDepartment->toDto()); |
35 | 35 | } |
36 | 36 |
@@ -18,12 +18,12 @@ discard block |
||
18 | 18 | ') |
19 | 19 | ->join('users', 'users.id', 'interactions.user_id') |
20 | 20 | ->join('contexts', 'users.context_id', 'contexts.id') |
21 | - ->where(function ($query) use ($type){ |
|
22 | - $query->when($type === 'follow', function ($query) { |
|
21 | + ->where(function($query) use ($type){ |
|
22 | + $query->when($type === 'follow', function($query) { |
|
23 | 23 | $query->where('follow', true); |
24 | 24 | $query->orWhere('done', true); |
25 | 25 | }) |
26 | - ->when($type === 'do', function ($query) { |
|
26 | + ->when($type === 'do', function($query) { |
|
27 | 27 | $query->where('done', true); |
28 | 28 | }); |
29 | 29 | }) |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | ->get(); |
34 | 34 | |
35 | 35 | $interactionsToReturn = []; |
36 | - foreach($interactions as $interaction){ |
|
36 | + foreach ($interactions as $interaction) { |
|
37 | 37 | $characteristicsModel = CharacteristicsModel::query()->where('code', $interaction->department)->first(); |
38 | 38 | |
39 | 39 | // FIXME : This test is only necessary because corsica breaks the line above. When corsica is correctly handled, |
@@ -58,12 +58,12 @@ discard block |
||
58 | 58 | ->join('contexts', 'users.context_id', 'contexts.id') |
59 | 59 | ->join('user_characteristics', 'user_characteristics.user_id', 'users.id') |
60 | 60 | ->join('characteristics', 'characteristics.id', 'user_characteristics.characteristic_id') |
61 | - ->where(function ($query) use ($type){ |
|
62 | - $query->when($type === 'follow', function ($query) { |
|
61 | + ->where(function($query) use ($type){ |
|
62 | + $query->when($type === 'follow', function($query) { |
|
63 | 63 | $query->where('follow', true); |
64 | 64 | $query->orWhere('done', true); |
65 | 65 | }) |
66 | - ->when($type === 'do', function ($query) { |
|
66 | + ->when($type === 'do', function($query) { |
|
67 | 67 | $query->where('done', true); |
68 | 68 | }); |
69 | 69 | }) |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | ->get(); |
77 | 77 | |
78 | 78 | $characteristicsToReturn = []; |
79 | - foreach($characteristicsCount as $characteristicCount){ |
|
79 | + foreach ($characteristicsCount as $characteristicCount) { |
|
80 | 80 | $characteristic = CharacteristicsModel::query()->find($characteristicCount->characteristic_id); |
81 | 81 | $characteristic->count = $characteristicCount->count; |
82 | 82 | $c = $characteristic->toArray(); |
@@ -38,8 +38,9 @@ |
||
38 | 38 | |
39 | 39 | // FIXME : This test is only necessary because corsica breaks the line above. When corsica is correctly handled, |
40 | 40 | // we should remove the test for emptyness. |
41 | - if (!empty($characteristicsModel)) |
|
42 | - $characteristicsModel->icon = route('api.icon.serve', ['id' => $characteristicsModel->uuid]); |
|
41 | + if (!empty($characteristicsModel)) { |
|
42 | + $characteristicsModel->icon = route('api.icon.serve', ['id' => $characteristicsModel->uuid]); |
|
43 | + } |
|
43 | 44 | |
44 | 45 | $interaction->departmentData = $characteristicsModel; |
45 | 46 | $interactionsToReturn[] = $interaction->toArray(); |