@@ -35,9 +35,10 @@ |
||
35 | 35 | Auth::guard('web')->loginUsingId($user_id); |
36 | 36 | } |
37 | 37 | |
38 | - if (!config('faithgen-sdk.source')) |
|
39 | - Auth::viaRequest('api-key', function ($request) { |
|
38 | + if (!config('faithgen-sdk.source')) { |
|
39 | + Auth::viaRequest('api-key', function ($request) { |
|
40 | 40 | $api_key = request()->headers->get('x-api-key'); |
41 | + } |
|
41 | 42 | $class = config('auth.providers.ministries.model'); |
42 | 43 | return $class::whereHas('apiKey', function ($apiKey) use ($api_key) { |
43 | 44 | return $apiKey->where('api_key', $api_key); |
@@ -10,9 +10,11 @@ |
||
10 | 10 | private $image; |
11 | 11 | function __construct(Image $image) |
12 | 12 | { |
13 | - if (request()->has('image_id')) |
|
14 | - $this->image = Image::findOrFail(request('image_id')); |
|
15 | - else $this->image = $image; |
|
13 | + if (request()->has('image_id')) { |
|
14 | + $this->image = Image::findOrFail(request('image_id')); |
|
15 | + } else { |
|
16 | + $this->image = $image; |
|
17 | + } |
|
16 | 18 | } |
17 | 19 | |
18 | 20 | /** |
@@ -15,8 +15,10 @@ |
||
15 | 15 | */ |
16 | 16 | public function handle($request, Closure $next) |
17 | 17 | { |
18 | - if (config('faithgen-sdk.source')) |
|
19 | - return $next($request); |
|
20 | - else abort(403, 'You are not allowed to perform this action'); |
|
18 | + if (config('faithgen-sdk.source')) { |
|
19 | + return $next($request); |
|
20 | + } else { |
|
21 | + abort(403, 'You are not allowed to perform this action'); |
|
22 | + } |
|
21 | 23 | } |
22 | 24 | } |
@@ -15,9 +15,10 @@ |
||
15 | 15 | */ |
16 | 16 | public function handle($request, Closure $next) |
17 | 17 | { |
18 | - if (auth(config('faithgen-sdk.guard'))->user()->activation->active) |
|
19 | - return $next($request); |
|
20 | - else |
|
21 | - abort(403, 'You need to activate you account first to access this part'); |
|
18 | + if (auth(config('faithgen-sdk.guard'))->user()->activation->active) { |
|
19 | + return $next($request); |
|
20 | + } else { |
|
21 | + abort(403, 'You need to activate you account first to access this part'); |
|
22 | + } |
|
22 | 23 | } |
23 | 24 | } |
@@ -18,10 +18,11 @@ |
||
18 | 18 | */ |
19 | 19 | public function toArray($request) |
20 | 20 | { |
21 | - if ($is_admin = Str::of($this->creatable_type)->contains('Ministry')) |
|
22 | - $avatar = ImageHelper::getImage('profile', $this->creatable->image, config('faithgen-sdk.ministries-server')); |
|
23 | - else |
|
24 | - $avatar = ImageHelper::getImage('users', $this->creatable->image, config('faithgen-sdk.users-server')); |
|
21 | + if ($is_admin = Str::of($this->creatable_type)->contains('Ministry')) { |
|
22 | + $avatar = ImageHelper::getImage('profile', $this->creatable->image, config('faithgen-sdk.ministries-server')); |
|
23 | + } else { |
|
24 | + $avatar = ImageHelper::getImage('users', $this->creatable->image, config('faithgen-sdk.users-server')); |
|
25 | + } |
|
25 | 26 | |
26 | 27 | return [ |
27 | 28 | 'id' => $this->id, |
@@ -13,9 +13,11 @@ discard block |
||
13 | 13 | */ |
14 | 14 | public function authorize() |
15 | 15 | { |
16 | - if ($this->route()->getName() === 'users.register') |
|
17 | - return true; |
|
18 | - else return auth('web')->user(); |
|
16 | + if ($this->route()->getName() === 'users.register') { |
|
17 | + return true; |
|
18 | + } else { |
|
19 | + return auth('web')->user(); |
|
20 | + } |
|
19 | 21 | } |
20 | 22 | |
21 | 23 | /** |
@@ -37,11 +39,13 @@ discard block |
||
37 | 39 | */ |
38 | 40 | public function rules() |
39 | 41 | { |
40 | - if ($this->route()->getName() === 'users.register') |
|
41 | - return $this->baseRules; |
|
42 | - else return array_merge($this->baseRules, [ |
|
42 | + if ($this->route()->getName() === 'users.register') { |
|
43 | + return $this->baseRules; |
|
44 | + } else { |
|
45 | + return array_merge($this->baseRules, [ |
|
43 | 46 | 'phone' => 'required|string' |
44 | 47 | ]); |
48 | + } |
|
45 | 49 | } |
46 | 50 | |
47 | 51 | public function messages() |
@@ -90,10 +90,11 @@ discard block |
||
90 | 90 | ProfileResource::withoutWrapping(); |
91 | 91 | MinistryResource::withoutWrapping(); |
92 | 92 | |
93 | - if (request()->has('complete') && request()->complete) |
|
94 | - return new ProfileResource(auth()->user()); |
|
95 | - else |
|
96 | - return new MinistryResource(auth()->user()); |
|
93 | + if (request()->has('complete') && request()->complete) { |
|
94 | + return new ProfileResource(auth()->user()); |
|
95 | + } else { |
|
96 | + return new MinistryResource(auth()->user()); |
|
97 | + } |
|
97 | 98 | } |
98 | 99 | |
99 | 100 | /** |
@@ -105,8 +106,9 @@ discard block |
||
105 | 106 | */ |
106 | 107 | function updatePhoto(UpdateImageRequest $request, ImageManager $imageManager) |
107 | 108 | { |
108 | - if (auth()->user()->image()->exists()) |
|
109 | - $this->deleteFiles(auth()->user()); |
|
109 | + if (auth()->user()->image()->exists()) { |
|
110 | + $this->deleteFiles(auth()->user()); |
|
111 | + } |
|
110 | 112 | |
111 | 113 | $fileName = str_shuffle(auth()->user()->id . time() . time()) . '.png'; |
112 | 114 | $ogSave = storage_path('app/public/profile/original/') . $fileName; |
@@ -138,8 +140,12 @@ discard block |
||
138 | 140 | } catch (\Exception $e) { |
139 | 141 | abort(500, $e->getMessage()); |
140 | 142 | } |
141 | - } else abort(500, 'News passwords did not match!'); |
|
142 | - } else abort(500, 'Current password is incorrect!'); |
|
143 | + } else { |
|
144 | + abort(500, 'News passwords did not match!'); |
|
145 | + } |
|
146 | + } else { |
|
147 | + abort(500, 'Current password is incorrect!'); |
|
148 | + } |
|
143 | 149 | } |
144 | 150 | |
145 | 151 | /** |
@@ -157,7 +163,9 @@ discard block |
||
157 | 163 | } catch (\Exception $e) { |
158 | 164 | abort(500, $e->getMessage()); |
159 | 165 | } |
160 | - } else abort(500, 'Password is incorrect!'); |
|
166 | + } else { |
|
167 | + abort(500, 'Password is incorrect!'); |
|
168 | + } |
|
161 | 169 | } |
162 | 170 | |
163 | 171 | /** |
@@ -185,8 +193,9 @@ discard block |
||
185 | 193 | |
186 | 194 | $params = array_merge($params, ['phones' => $request->phones]); |
187 | 195 | |
188 | - if ($request->has('location')) |
|
189 | - $params = array_merge($params, ['location' => $request->location]); |
|
196 | + if ($request->has('location')) { |
|
197 | + $params = array_merge($params, ['location' => $request->location]); |
|
198 | + } |
|
190 | 199 | |
191 | 200 | $this->saveServices($request, auth()->user()); |
192 | 201 |
@@ -67,9 +67,11 @@ discard block |
||
67 | 67 | ->whereHas('user', fn($user) => $user->where($request->validated())) |
68 | 68 | ->first(); |
69 | 69 | |
70 | - if ($ministryUser) |
|
71 | - return $this->processResponse($request, $ministryUser, 'Login successful.'); |
|
72 | - else abort(401, 'This phone number is not valid for this app'); |
|
70 | + if ($ministryUser) { |
|
71 | + return $this->processResponse($request, $ministryUser, 'Login successful.'); |
|
72 | + } else { |
|
73 | + abort(401, 'This phone number is not valid for this app'); |
|
74 | + } |
|
73 | 75 | } |
74 | 76 | |
75 | 77 | /** |
@@ -87,10 +89,11 @@ discard block |
||
87 | 89 | 'processing_image' => $request->has('image') |
88 | 90 | ]; |
89 | 91 | |
90 | - if (!$request->has('image')) |
|
91 | - return $this->successResponse($messagePrefix, $data); |
|
92 | - else |
|
93 | - return $this->successResponse($messagePrefix . ' We are uploading your picture now', $data); |
|
92 | + if (!$request->has('image')) { |
|
93 | + return $this->successResponse($messagePrefix, $data); |
|
94 | + } else { |
|
95 | + return $this->successResponse($messagePrefix . ' We are uploading your picture now', $data); |
|
96 | + } |
|
94 | 97 | } |
95 | 98 | |
96 | 99 | /** |
@@ -50,8 +50,9 @@ discard block |
||
50 | 50 | } catch (\Exception $e) { |
51 | 51 | abort(500, $e->getMessage()); |
52 | 52 | } |
53 | - } else |
|
54 | - abort(500, 'Passwords did not match'); |
|
53 | + } else { |
|
54 | + abort(500, 'Passwords did not match'); |
|
55 | + } |
|
55 | 56 | } |
56 | 57 | |
57 | 58 | function login(LoginRequest $request) |
@@ -71,8 +72,9 @@ discard block |
||
71 | 72 | } catch (\Exception $e) { |
72 | 73 | abort(500, $e->getMessage()); |
73 | 74 | } |
74 | - } else |
|
75 | - abort(500, 'Activation code is incorrect!'); |
|
75 | + } else { |
|
76 | + abort(500, 'Activation code is incorrect!'); |
|
77 | + } |
|
76 | 78 | return $ministry; |
77 | 79 | } |
78 | 80 | |
@@ -82,8 +84,9 @@ discard block |
||
82 | 84 | if ($ministry) { |
83 | 85 | $ministry->notify(new ForgotPassword($ministry)); |
84 | 86 | return $this->successResponse('We have emailed you a reset password email, please follow it to to update your password'); |
85 | - } else |
|
86 | - abort(500, 'Account with email not found!'); |
|
87 | + } else { |
|
88 | + abort(500, 'Account with email not found!'); |
|
89 | + } |
|
87 | 90 | } |
88 | 91 | |
89 | 92 | function resendActivation() |