@@ -106,7 +106,7 @@ |
||
106 | 106 | */ |
107 | 107 | public function validFrom(Carbon $date) |
108 | 108 | { |
109 | - $this->data['valid_from'] = $date ? : now(); |
|
109 | + $this->data['valid_from'] = $date ?: now(); |
|
110 | 110 | |
111 | 111 | return $this; |
112 | 112 | } |
@@ -47,10 +47,11 @@ discard block |
||
47 | 47 | */ |
48 | 48 | public function get() |
49 | 49 | { |
50 | - if (!blank(optional($this->data)['email'])) |
|
51 | - $result = Invite::valid()->whereEmail($this->data['email'])->first(); |
|
52 | - else |
|
53 | - $result = Invite::valid()->get(); |
|
50 | + if (!blank(optional($this->data)['email'])) { |
|
51 | + $result = Invite::valid()->whereEmail($this->data['email'])->first(); |
|
52 | + } else { |
|
53 | + $result = Invite::valid()->get(); |
|
54 | + } |
|
54 | 55 | |
55 | 56 | $this->initializeData(); |
56 | 57 | |
@@ -75,8 +76,9 @@ discard block |
||
75 | 76 | $validator = Validator::make(compact('email'), [ |
76 | 77 | 'email'=>'required|email' |
77 | 78 | ]); |
78 | - if ($validator->fails()) |
|
79 | - throw new InvalidEmailIdException; |
|
79 | + if ($validator->fails()) { |
|
80 | + throw new InvalidEmailIdException; |
|
81 | + } |
|
80 | 82 | |
81 | 83 | $this->data['email'] = $email; |
82 | 84 | |
@@ -92,8 +94,9 @@ discard block |
||
92 | 94 | { |
93 | 95 | $invite = Invite::create($this->data); |
94 | 96 | |
95 | - if ($invite->email && config('laravelinvites.mail.enabled', true)) |
|
96 | - Mail::to($invite->email)->send(new InvitationMail($invite)); |
|
97 | + if ($invite->email && config('laravelinvites.mail.enabled', true)) { |
|
98 | + Mail::to($invite->email)->send(new InvitationMail($invite)); |
|
99 | + } |
|
97 | 100 | |
98 | 101 | return $invite; |
99 | 102 | } |
@@ -118,8 +121,9 @@ discard block |
||
118 | 121 | */ |
119 | 122 | private function prepare() |
120 | 123 | { |
121 | - if ($this->number_of_invites == 1) |
|
122 | - return $this->prepareSingle(); |
|
124 | + if ($this->number_of_invites == 1) { |
|
125 | + return $this->prepareSingle(); |
|
126 | + } |
|
123 | 127 | |
124 | 128 | $invites = []; |
125 | 129 | |
@@ -142,15 +146,17 @@ discard block |
||
142 | 146 | { |
143 | 147 | if (optional($this->data)['email'] && !blank($this->data['email'])) |
144 | 148 | { |
145 | - if ($number_of_invites > 1) |
|
146 | - throw new AnEmailCanHaveOnlyOneInvitation; |
|
149 | + if ($number_of_invites > 1) { |
|
150 | + throw new AnEmailCanHaveOnlyOneInvitation; |
|
151 | + } |
|
147 | 152 | |
148 | 153 | $validator = Validator::make($this->data, [ |
149 | 154 | 'email'=>'unique:'.config('laravelinvites.table').',email' |
150 | 155 | ]); |
151 | 156 | |
152 | - if ($validator->fails()) |
|
153 | - throw new AnEmailCanHaveOnlyOneInvitation; |
|
157 | + if ($validator->fails()) { |
|
158 | + throw new AnEmailCanHaveOnlyOneInvitation; |
|
159 | + } |
|
154 | 160 | } |
155 | 161 | } |
156 | 162 | |
@@ -272,28 +278,23 @@ discard block |
||
272 | 278 | |
273 | 279 | $this->check($value, $email); |
274 | 280 | return true; |
275 | - } |
|
276 | - catch (InvalidInvitationCodeException $e) |
|
281 | + } catch (InvalidInvitationCodeException $e) |
|
277 | 282 | { |
278 | 283 | $validator->errors()->add($emailFieldName, ':attribute is invalid'); |
279 | 284 | return false; |
280 | - } |
|
281 | - catch (InvitationNotYetActiveException $e) |
|
285 | + } catch (InvitationNotYetActiveException $e) |
|
282 | 286 | { |
283 | 287 | $validator->errors()->add($emailFieldName, ':attribute is not valid yet'); |
284 | 288 | return false; |
285 | - } |
|
286 | - catch (InvitationExpiredException $e) |
|
289 | + } catch (InvitationExpiredException $e) |
|
287 | 290 | { |
288 | 291 | $validator->errors()->add($emailFieldName, ':attribute expired'); |
289 | 292 | return false; |
290 | - } |
|
291 | - catch (InvitationNotValidWithEmailException $e) |
|
293 | + } catch (InvitationNotValidWithEmailException $e) |
|
292 | 294 | { |
293 | 295 | $validator->errors()->add($emailFieldName, ':attribute is not valid with the provided '.$emailFieldName); |
294 | 296 | return false; |
295 | - } |
|
296 | - catch (MaximumUseOfCodeException $e) |
|
297 | + } catch (MaximumUseOfCodeException $e) |
|
297 | 298 | { |
298 | 299 | $validator->errors()->add($emailFieldName, ':attribute has been used for the maximum possible times'); |
299 | 300 | return false; |
@@ -316,8 +317,7 @@ discard block |
||
316 | 317 | $this->check($code, $email); |
317 | 318 | |
318 | 319 | return true; |
319 | - } |
|
320 | - catch (LaravelInvitesException $e) |
|
320 | + } catch (LaravelInvitesException $e) |
|
321 | 321 | { |
322 | 322 | return false; |
323 | 323 | } |
@@ -335,20 +335,25 @@ discard block |
||
335 | 335 | { |
336 | 336 | $invite = Invite::whereCode($code)->first(); |
337 | 337 | |
338 | - if (!$invite) |
|
339 | - throw new InvalidInvitationCodeException; |
|
338 | + if (!$invite) { |
|
339 | + throw new InvalidInvitationCodeException; |
|
340 | + } |
|
340 | 341 | |
341 | - if ($invite->valid_from > now()) |
|
342 | - throw new InvitationNotYetActiveException($invite->valid_from); |
|
342 | + if ($invite->valid_from > now()) { |
|
343 | + throw new InvitationNotYetActiveException($invite->valid_from); |
|
344 | + } |
|
343 | 345 | |
344 | - if ($invite->valid_upto && $invite->valid_upto <= now()) |
|
345 | - throw new InvitationExpiredException($invite->valid_upto); |
|
346 | + if ($invite->valid_upto && $invite->valid_upto <= now()) { |
|
347 | + throw new InvitationExpiredException($invite->valid_upto); |
|
348 | + } |
|
346 | 349 | |
347 | - if ($invite->used_count > ($invite->allowed_count - 1)) |
|
348 | - throw new MaximumUseOfCodeException($invite->allowed_count); |
|
350 | + if ($invite->used_count > ($invite->allowed_count - 1)) { |
|
351 | + throw new MaximumUseOfCodeException($invite->allowed_count); |
|
352 | + } |
|
349 | 353 | |
350 | - if ($invite->email !== $email && !blank($invite->email)) |
|
351 | - throw new InvitationNotValidWithEmailException($email, $invite->email); |
|
354 | + if ($invite->email !== $email && !blank($invite->email)) { |
|
355 | + throw new InvitationNotValidWithEmailException($email, $invite->email); |
|
356 | + } |
|
352 | 357 | |
353 | 358 | return true; |
354 | 359 | } |