@@ -47,8 +47,7 @@ |
||
47 | 47 | try { |
48 | 48 | LaravelInvites::check($code, $email); |
49 | 49 | $this->info('This code is valid'); |
50 | - } |
|
51 | - catch(LaravelInvitesException $e) |
|
50 | + } catch(LaravelInvitesException $e) |
|
52 | 51 | { |
53 | 52 | $this->error($e->getMessage()); |
54 | 53 | } |
@@ -42,8 +42,7 @@ |
||
42 | 42 | if($this->invite->valid_upto) |
43 | 43 | { |
44 | 44 | $url = URL::temporarySignedRoute('laravelinvites.routes.follow', $this->invite->valid_upto, $data); |
45 | - } |
|
46 | - else |
|
45 | + } else |
|
47 | 46 | { |
48 | 47 | $url = URL::signedRoute('laravelinvites.routes.follow', $data); |
49 | 48 | } |
@@ -37,8 +37,9 @@ discard block |
||
37 | 37 | { |
38 | 38 | $this->increment('used_count'); |
39 | 39 | |
40 | - if($this->used_count >= $this->allowed_count && config('laravelinvites.delete_on_full', true)) |
|
41 | - $this->delete(); |
|
40 | + if($this->used_count >= $this->allowed_count && config('laravelinvites.delete_on_full', true)) { |
|
41 | + $this->delete(); |
|
42 | + } |
|
42 | 43 | } |
43 | 44 | |
44 | 45 | public function scopeValid($query) |
@@ -59,13 +60,14 @@ discard block |
||
59 | 60 | */ |
60 | 61 | private function setDefaultExpiry() |
61 | 62 | { |
62 | - if(config('laravelinvites.expiry.type')==='none') |
|
63 | - return null; |
|
63 | + if(config('laravelinvites.expiry.type')==='none') { |
|
64 | + return null; |
|
65 | + } |
|
64 | 66 | |
65 | - if(config('laravelinvites.expiry.type') === 'hours') |
|
66 | - return now()->addHours(config('laravelinvites.expiry.value')); |
|
67 | - |
|
68 | - elseif(config('laravelinvites.expiry.type') === "days") |
|
69 | - return now()->addDays(config('laravelinvites.expiry.days')); |
|
67 | + if(config('laravelinvites.expiry.type') === 'hours') { |
|
68 | + return now()->addHours(config('laravelinvites.expiry.value')); |
|
69 | + } elseif(config('laravelinvites.expiry.type') === "days") { |
|
70 | + return now()->addDays(config('laravelinvites.expiry.days')); |
|
71 | + } |
|
70 | 72 | } |
71 | 73 | } |
72 | 74 | \ No newline at end of file |
@@ -8,9 +8,10 @@ |
||
8 | 8 | { |
9 | 9 | public function __construct($email, $valid_email) |
10 | 10 | { |
11 | - if($email) |
|
12 | - parent::__construct("This invitation code is not valid with this $email"); |
|
13 | - else |
|
14 | - parent::__construct("This invitation code is valid only for $valid_email"); |
|
11 | + if($email) { |
|
12 | + parent::__construct("This invitation code is not valid with this $email"); |
|
13 | + } else { |
|
14 | + parent::__construct("This invitation code is valid only for $valid_email"); |
|
15 | + } |
|
15 | 16 | } |
16 | 17 | } |
@@ -49,12 +49,15 @@ |
||
49 | 49 | $hours = (int) $this->option('hours'); |
50 | 50 | $days = (int) $this->option('days'); |
51 | 51 | |
52 | - $invite = LaravelInvites::for($email)->allow($allow); |
|
52 | + $invite = LaravelInvites::for($email) { |
|
53 | + ->allow($allow); |
|
54 | + } |
|
53 | 55 | |
54 | - if($days) |
|
55 | - $invite->setExpiry(now()->addDays($days)); |
|
56 | - else if($hours) |
|
57 | - $invite->setExpiry(now()->addHours($hours)); |
|
56 | + if($days) { |
|
57 | + $invite->setExpiry(now()->addDays($days)); |
|
58 | + } else if($hours) { |
|
59 | + $invite->setExpiry(now()->addHours($hours)); |
|
60 | + } |
|
58 | 61 | |
59 | 62 | $invite->generate($count); |
60 | 63 |
@@ -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 | |
@@ -140,15 +144,17 @@ discard block |
||
140 | 144 | { |
141 | 145 | if(optional($this->data)['email'] && !blank($this->data['email'])) |
142 | 146 | { |
143 | - if($number_of_invites > 1) |
|
144 | - throw new AnEmailCanHaveOnlyOneInvitation; |
|
147 | + if($number_of_invites > 1) { |
|
148 | + throw new AnEmailCanHaveOnlyOneInvitation; |
|
149 | + } |
|
145 | 150 | |
146 | 151 | $validator = Validator::make($this->data,[ |
147 | 152 | 'email'=>'unique:'.config('laravelinvites.table').',email' |
148 | 153 | ]); |
149 | 154 | |
150 | - if($validator->fails()) |
|
151 | - throw new AnEmailCanHaveOnlyOneInvitation; |
|
155 | + if($validator->fails()) { |
|
156 | + throw new AnEmailCanHaveOnlyOneInvitation; |
|
157 | + } |
|
152 | 158 | } |
153 | 159 | } |
154 | 160 | |
@@ -270,28 +276,23 @@ discard block |
||
270 | 276 | |
271 | 277 | $this->check($code, $email); |
272 | 278 | return true; |
273 | - } |
|
274 | - catch(InvalidInvitationCodeException $e) |
|
279 | + } catch(InvalidInvitationCodeException $e) |
|
275 | 280 | { |
276 | 281 | $validator->errors()->add($emailFieldName, ':attribute is invalid'); |
277 | 282 | return false; |
278 | - } |
|
279 | - catch(InvitationNotYetActiveException $e) |
|
283 | + } catch(InvitationNotYetActiveException $e) |
|
280 | 284 | { |
281 | 285 | $validator->errors()->add($emailFieldName, ':attribute is not valid yet'); |
282 | 286 | return false; |
283 | - } |
|
284 | - catch(InvitationExpiredException $e) |
|
287 | + } catch(InvitationExpiredException $e) |
|
285 | 288 | { |
286 | 289 | $validator->errors()->add($emailFieldName, ':attribute expired'); |
287 | 290 | return false; |
288 | - } |
|
289 | - catch(InvitationNotValidWithEmailException $e) |
|
291 | + } catch(InvitationNotValidWithEmailException $e) |
|
290 | 292 | { |
291 | 293 | $validator->errors()->add($emailFieldName, ':attribute is not valid with the provided '.$emailFieldName); |
292 | 294 | return false; |
293 | - } |
|
294 | - catch(MaximumUseOfCodeException $e) |
|
295 | + } catch(MaximumUseOfCodeException $e) |
|
295 | 296 | { |
296 | 297 | $validator->errors()->add($emailFieldName, ':attribute has been used for the maximum possible times'); |
297 | 298 | return false; |
@@ -314,8 +315,7 @@ discard block |
||
314 | 315 | $this->check($code, $email); |
315 | 316 | |
316 | 317 | return true; |
317 | - } |
|
318 | - catch(LaravelInvitesException $e) |
|
318 | + } catch(LaravelInvitesException $e) |
|
319 | 319 | { |
320 | 320 | return false; |
321 | 321 | } |
@@ -333,20 +333,25 @@ discard block |
||
333 | 333 | { |
334 | 334 | $invite = Invite::whereCode($code)->first(); |
335 | 335 | |
336 | - if(!$invite) |
|
337 | - throw new InvalidInvitationCodeException; |
|
336 | + if(!$invite) { |
|
337 | + throw new InvalidInvitationCodeException; |
|
338 | + } |
|
338 | 339 | |
339 | - if($invite->valid_from > now()) |
|
340 | - throw new InvitationNotYetActiveException($invite->valid_from); |
|
340 | + if($invite->valid_from > now()) { |
|
341 | + throw new InvitationNotYetActiveException($invite->valid_from); |
|
342 | + } |
|
341 | 343 | |
342 | - if($invite->valid_upto && $invite->valid_upto <= now()) |
|
343 | - throw new InvitationExpiredException($invite->valid_upto); |
|
344 | + if($invite->valid_upto && $invite->valid_upto <= now()) { |
|
345 | + throw new InvitationExpiredException($invite->valid_upto); |
|
346 | + } |
|
344 | 347 | |
345 | - if($invite->used_count > ($invite->allowed_count-1)) |
|
346 | - throw new MaximumUseOfCodeException($invite->allowed_count); |
|
348 | + if($invite->used_count > ($invite->allowed_count-1)) { |
|
349 | + throw new MaximumUseOfCodeException($invite->allowed_count); |
|
350 | + } |
|
347 | 351 | |
348 | - if($invite->email !== $email && !blank($invite->email)) |
|
349 | - throw new InvitationNotValidWithEmailException($email, $invite->email); |
|
352 | + if($invite->email !== $email && !blank($invite->email)) { |
|
353 | + throw new InvitationNotValidWithEmailException($email, $invite->email); |
|
354 | + } |
|
350 | 355 | |
351 | 356 | return true; |
352 | 357 | } |