@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | { |
25 | 25 | $httpClient = new Client(); |
26 | 26 | |
27 | - PageModel::query()->where('dry', true)->chunkById(50, function ($items, $count) use($httpClient){ |
|
27 | + PageModel::query()->where('dry', true)->chunkById(50, function($items, $count) use($httpClient){ |
|
28 | 28 | $this->info(($count*50).' Pages'); |
29 | 29 | $pages = $items->pluck('page_id')->toArray(); |
30 | 30 | $pagesApiUri = config('wiki.api_uri').$this->queryPages.implode('|', $pages); |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | $content = json_decode($response->getBody()->getContents(), true); |
33 | 33 | $wikiPages = $content['query']['pages']; |
34 | 34 | |
35 | - foreach($wikiPages as $page){ |
|
35 | + foreach ($wikiPages as $page) { |
|
36 | 36 | $pageModel = PageModel::query()->where('page_id', $page['pageid'])->first(); |
37 | 37 | |
38 | 38 | if (!isset($page['title'])) |
@@ -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(); |
@@ -61,14 +61,14 @@ discard block |
||
61 | 61 | return $this->firstname.' '.$this->lastname; |
62 | 62 | } |
63 | 63 | |
64 | - public function organizationId():?string |
|
64 | + public function organizationId(): ?string |
|
65 | 65 | { |
66 | 66 | return $this->organizationId; |
67 | 67 | } |
68 | 68 | |
69 | 69 | public function provider(string $provider, string $providerId):bool |
70 | 70 | { |
71 | - if(isset($this->providers[$provider]) && $this->providers[$provider] == $providerId){ |
|
71 | + if (isset($this->providers[$provider]) && $this->providers[$provider] == $providerId) { |
|
72 | 72 | return true; |
73 | 73 | } |
74 | 74 | return false; |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | |
88 | 88 | public function create(string $passwordHashed = null, Picture $picture = null) |
89 | 89 | { |
90 | - if(isset($picture)) { |
|
91 | - $picture->resize('app/public/users/' . $this->id); |
|
90 | + if (isset($picture)) { |
|
91 | + $picture->resize('app/public/users/'.$this->id); |
|
92 | 92 | $this->pathPicture = $picture->relativePath(); |
93 | 93 | } |
94 | 94 | app(UserRepository::class)->add($this, $passwordHashed); |
@@ -130,20 +130,20 @@ discard block |
||
130 | 130 | $this->email = $email; |
131 | 131 | $this->firstname = $firstname; |
132 | 132 | $this->lastname = $lastname; |
133 | - if($pathPicture !== "") { |
|
133 | + if ($pathPicture !== "") { |
|
134 | 134 | $picture = new Picture($pathPicture); |
135 | - $picture->resize('app/public/users/' . $this->id . '.' . $ext); |
|
136 | - $this->pathPicture = 'app/public/users/' . $this->id . '.' . $ext; |
|
135 | + $picture->resize('app/public/users/'.$this->id.'.'.$ext); |
|
136 | + $this->pathPicture = 'app/public/users/'.$this->id.'.'.$ext; |
|
137 | 137 | } |
138 | 138 | app(UserRepository::class)->update($this); |
139 | 139 | } |
140 | 140 | |
141 | 141 | public function updateAvatar(string $pathPicture, string $ext = 'jpg') |
142 | 142 | { |
143 | - if($pathPicture !== "") { |
|
143 | + if ($pathPicture !== "") { |
|
144 | 144 | $picture = new Picture($pathPicture); |
145 | - $picture->resize('app/public/users/' . $this->id . '.' . $ext); |
|
146 | - $this->pathPicture = 'app/public/users/' . $this->id . '.' . $ext; |
|
145 | + $picture->resize('app/public/users/'.$this->id.'.'.$ext); |
|
146 | + $this->pathPicture = 'app/public/users/'.$this->id.'.'.$ext; |
|
147 | 147 | } |
148 | 148 | app(UserRepository::class)->update($this); |
149 | 149 | return $this->pathPicture; |
@@ -9,8 +9,8 @@ |
||
9 | 9 | |
10 | 10 | interface ContextRepository |
11 | 11 | { |
12 | - public function getByUser(string $userId):?Context; |
|
12 | + public function getByUser(string $userId): ?Context; |
|
13 | 13 | public function add(Context $context, string $userId); |
14 | 14 | public function update(Context $context, string $userId); |
15 | - public function getByUserDto(string $userId):?ContextDto; |
|
15 | + public function getByUserDto(string $userId): ?ContextDto; |
|
16 | 16 | } |
@@ -23,7 +23,7 @@ |
||
23 | 23 | $content = json_decode($response->getBody()->getContents(), true); |
24 | 24 | |
25 | 25 | $features = $content['features']; |
26 | - if(isset($features) && !empty($features)){ |
|
26 | + if (isset($features) && !empty($features)) { |
|
27 | 27 | $feature = $features[0]; |
28 | 28 | $coordinates = $feature['geometry']['coordinates']; |
29 | 29 | $departmentNumber = explode(',', $feature['properties']['context'])[0]; |
@@ -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 | ; |
@@ -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; |
@@ -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 ?? []; |