@@ -49,7 +49,7 @@ |
||
| 49 | 49 | $this->mergeConfigFrom(__DIR__.'/../config/laravelinvites.php', 'laravelinvites'); |
| 50 | 50 | |
| 51 | 51 | // Register the service the package provides. |
| 52 | - $this->app->singleton('laravelinvites', function ($app) { |
|
| 52 | + $this->app->singleton('laravelinvites', function($app) { |
|
| 53 | 53 | return new LaravelInvites; |
| 54 | 54 | }); |
| 55 | 55 | } |
@@ -41,14 +41,14 @@ |
||
| 41 | 41 | */ |
| 42 | 42 | public function handle() |
| 43 | 43 | { |
| 44 | - $email = $this->argument('email') ? : null; |
|
| 44 | + $email = $this->argument('email') ?: null; |
|
| 45 | 45 | $code = $this->argument('code'); |
| 46 | 46 | |
| 47 | 47 | try { |
| 48 | 48 | LaravelInvites::check($code, $email); |
| 49 | 49 | $this->info('This code is valid'); |
| 50 | 50 | } |
| 51 | - catch(LaravelInvitesException $e) |
|
| 51 | + catch (LaravelInvitesException $e) |
|
| 52 | 52 | { |
| 53 | 53 | $this->error($e->getMessage()); |
| 54 | 54 | } |
@@ -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 | } |
@@ -43,17 +43,17 @@ |
||
| 43 | 43 | */ |
| 44 | 44 | public function handle() |
| 45 | 45 | { |
| 46 | - $email = $this->argument('email') ? : null; |
|
| 46 | + $email = $this->argument('email') ?: null; |
|
| 47 | 47 | $allow = $this->option('allow'); |
| 48 | 48 | $count = $this->option('count'); |
| 49 | 49 | $hours = $this->option('hours'); |
| 50 | 50 | $days = $this->option('days'); |
| 51 | 51 | |
| 52 | - $invite = LaravelInvites::for($email)->allow($allow); |
|
| 52 | + $invite = LaravelInvites::for ($email)->allow($allow); |
|
| 53 | 53 | |
| 54 | - if($days) |
|
| 54 | + if ($days) |
|
| 55 | 55 | $invite->setExpiry(now()->addDays($days)); |
| 56 | - else if($hours) |
|
| 56 | + else if ($hours) |
|
| 57 | 57 | $invite->setExpiry(now()->addHours($hours)); |
| 58 | 58 | |
| 59 | 59 | $invites = $invite->generate($count); |
@@ -49,12 +49,15 @@ |
||
| 49 | 49 | $hours = $this->option('hours'); |
| 50 | 50 | $days = $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 | $invites = $invite->generate($count); |
| 60 | 63 | |
@@ -39,7 +39,7 @@ |
||
| 39 | 39 | 'code' => (string) $this->invite->code |
| 40 | 40 | ]; |
| 41 | 41 | |
| 42 | - if($this->invite->valid_upto) |
|
| 42 | + if ($this->invite->valid_upto) |
|
| 43 | 43 | { |
| 44 | 44 | $url = URL::temporarySignedRoute('laravelinvites.routes.follow', $this->invite->valid_upto, $data); |
| 45 | 45 | } |
@@ -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 | } |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | public function up() |
| 15 | 15 | { |
| 16 | - Schema::create(config('laravelinvites.table'), function (Blueprint $table) { |
|
| 16 | + Schema::create(config('laravelinvites.table'), function(Blueprint $table) { |
|
| 17 | 17 | $table->increments('id'); |
| 18 | 18 | $table->string('email')->nullable()->unique(); |
| 19 | 19 | $table->string('code')->unique(); |
@@ -37,13 +37,13 @@ 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)) |
|
| 40 | + if ($this->used_count >= $this->allowed_count && config('laravelinvites.delete_on_full', true)) |
|
| 41 | 41 | $this->delete(); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | public function scopeValid($query) |
| 45 | 45 | { |
| 46 | - return $query->where('valid_from','<=', now()) |
|
| 46 | + return $query->where('valid_from', '<=', now()) |
|
| 47 | 47 | ->where('valid_upto', '>=', now()) |
| 48 | 48 | ->whereRaw('allowed_count > used_count'); |
| 49 | 49 | } |
@@ -59,13 +59,13 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | private function setDefaultExpiry() |
| 61 | 61 | { |
| 62 | - if(config('laravelinvites.expiry.type')==='none') |
|
| 62 | + if (config('laravelinvites.expiry.type') === 'none') |
|
| 63 | 63 | return null; |
| 64 | 64 | |
| 65 | - if(config('laravelinvites.expiry.type') === 'hours') |
|
| 65 | + if (config('laravelinvites.expiry.type') === 'hours') |
|
| 66 | 66 | return now()->addHours(config('laravelinvites.expiry.value')); |
| 67 | 67 | |
| 68 | - elseif(config('laravelinvites.expiry.type') === "days") |
|
| 68 | + elseif (config('laravelinvites.expiry.type') === "days") |
|
| 69 | 69 | return now()->addDays(config('laravelinvites.expiry.days')); |
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | \ No newline at end of file |
@@ -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,7 +8,7 @@ |
||
| 8 | 8 | { |
| 9 | 9 | public function __construct($email, $valid_email) |
| 10 | 10 | { |
| 11 | - if($email) |
|
| 11 | + if ($email) |
|
| 12 | 12 | parent::__construct("This invitation code is not valid with this $email"); |
| 13 | 13 | else |
| 14 | 14 | parent::__construct("This invitation code is valid only for $valid_email"); |
@@ -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 | } |
@@ -44,8 +44,8 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | public function get() |
| 46 | 46 | { |
| 47 | - if(!blank(optional($this->data)['email'])) |
|
| 48 | - $result = Invite::valid()->whereEmail($this->data['email'])->first(); |
|
| 47 | + if (!blank(optional($this->data)['email'])) |
|
| 48 | + $result = Invite::valid()->whereEmail($this->data['email'])->first(); |
|
| 49 | 49 | else |
| 50 | 50 | $result = Invite::valid()->get(); |
| 51 | 51 | |
@@ -54,18 +54,18 @@ discard block |
||
| 54 | 54 | return $result; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - public function for($email=null) |
|
| 57 | + public function for ($email = null) |
|
| 58 | 58 | { |
| 59 | - if(!$email) |
|
| 59 | + if (!$email) |
|
| 60 | 60 | { |
| 61 | 61 | unset($this->data['email']); |
| 62 | 62 | return $this; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - $validator = Validator::make(compact('email'),[ |
|
| 65 | + $validator = Validator::make(compact('email'), [ |
|
| 66 | 66 | 'email'=>'required|email' |
| 67 | 67 | ]); |
| 68 | - if($validator->fails()) |
|
| 68 | + if ($validator->fails()) |
|
| 69 | 69 | throw new InvalidEmailIdException; |
| 70 | 70 | |
| 71 | 71 | $this->data['email'] = $email; |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | { |
| 78 | 78 | $invite = Invite::create($this->data); |
| 79 | 79 | |
| 80 | - if($invite->email && config('laravelinvites.mail.enabled', true)) |
|
| 80 | + if ($invite->email && config('laravelinvites.mail.enabled', true)) |
|
| 81 | 81 | Mail::to($invite->email)->send(new InvitationMail($invite)); |
| 82 | 82 | |
| 83 | 83 | return $invite; |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | public function validFrom($date = null) |
| 87 | 87 | { |
| 88 | - $this->data['valid_from'] = $date ? : now(); |
|
| 88 | + $this->data['valid_from'] = $date ?: now(); |
|
| 89 | 89 | |
| 90 | 90 | return $this; |
| 91 | 91 | } |
@@ -97,12 +97,12 @@ discard block |
||
| 97 | 97 | */ |
| 98 | 98 | private function prepare() |
| 99 | 99 | { |
| 100 | - if($this->number_of_invites == 1) |
|
| 100 | + if ($this->number_of_invites == 1) |
|
| 101 | 101 | return $this->prepareSingle(); |
| 102 | 102 | |
| 103 | 103 | $invites = []; |
| 104 | 104 | |
| 105 | - for($i = 0; $i < $this->number_of_invites; $i++) |
|
| 105 | + for ($i = 0; $i < $this->number_of_invites; $i++) |
|
| 106 | 106 | { |
| 107 | 107 | $invites[] = $this->prepareSingle(); |
| 108 | 108 | } |
@@ -119,22 +119,22 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | public function generate($number_of_invites = 1) |
| 121 | 121 | { |
| 122 | - if(optional($this->data)['email'] && !blank($this->data['email'])) |
|
| 122 | + if (optional($this->data)['email'] && !blank($this->data['email'])) |
|
| 123 | 123 | { |
| 124 | - if($number_of_invites > 1) |
|
| 124 | + if ($number_of_invites > 1) |
|
| 125 | 125 | throw new AnEmailCanHaveOnlyOneInvitation; |
| 126 | 126 | |
| 127 | - $validator = Validator::make($this->data,[ |
|
| 127 | + $validator = Validator::make($this->data, [ |
|
| 128 | 128 | 'email'=>'unique:'.config('laravelinvites.table').',email' |
| 129 | 129 | ]); |
| 130 | 130 | |
| 131 | - if($validator->fails()) |
|
| 131 | + if ($validator->fails()) |
|
| 132 | 132 | throw new AnEmailCanHaveOnlyOneInvitation; |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | $this->number_of_invites = $number_of_invites; |
| 136 | 136 | |
| 137 | - $invitations = $this->prepare(); |
|
| 137 | + $invitations = $this->prepare(); |
|
| 138 | 138 | |
| 139 | 139 | $this->initializeData(); |
| 140 | 140 | |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | |
| 208 | 208 | private function getEmailParameter($parameters) |
| 209 | 209 | { |
| 210 | - return $parameters[0] ? : 'email' ; |
|
| 210 | + return $parameters[0] ?: 'email'; |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | public function validate($attribute, $value, $parameters, $validator) |
@@ -220,27 +220,27 @@ discard block |
||
| 220 | 220 | $this->check($code, $email); |
| 221 | 221 | return true; |
| 222 | 222 | } |
| 223 | - catch(InvalidInvitationCodeException $e) |
|
| 223 | + catch (InvalidInvitationCodeException $e) |
|
| 224 | 224 | { |
| 225 | 225 | $validator->errors()->add($emailFieldName, ':attribute is invalid'); |
| 226 | 226 | return false; |
| 227 | 227 | } |
| 228 | - catch(InvitationNotYetActiveException $e) |
|
| 228 | + catch (InvitationNotYetActiveException $e) |
|
| 229 | 229 | { |
| 230 | 230 | $validator->errors()->add($emailFieldName, ':attribute is not valid yet'); |
| 231 | 231 | return false; |
| 232 | 232 | } |
| 233 | - catch(InvitationExpiredException $e) |
|
| 233 | + catch (InvitationExpiredException $e) |
|
| 234 | 234 | { |
| 235 | 235 | $validator->errors()->add($emailFieldName, ':attribute expired'); |
| 236 | 236 | return false; |
| 237 | 237 | } |
| 238 | - catch(InvitationNotValidWithEmailException $e) |
|
| 238 | + catch (InvitationNotValidWithEmailException $e) |
|
| 239 | 239 | { |
| 240 | 240 | $validator->errors()->add($emailFieldName, ':attribute is not valid with the provided '.$emailFieldName); |
| 241 | 241 | return false; |
| 242 | 242 | } |
| 243 | - catch(MaximumUseOfCodeException $e) |
|
| 243 | + catch (MaximumUseOfCodeException $e) |
|
| 244 | 244 | { |
| 245 | 245 | $validator->errors()->add($emailFieldName, ':attribute has been used for the maximum possible times'); |
| 246 | 246 | return false; |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | |
| 263 | 263 | return true; |
| 264 | 264 | } |
| 265 | - catch(LaravelInvitesException $e) |
|
| 265 | + catch (LaravelInvitesException $e) |
|
| 266 | 266 | { |
| 267 | 267 | return false; |
| 268 | 268 | } |
@@ -274,23 +274,23 @@ discard block |
||
| 274 | 274 | * @param string $code |
| 275 | 275 | * @param string $email |
| 276 | 276 | */ |
| 277 | - public function check($code, $email=null) |
|
| 277 | + public function check($code, $email = null) |
|
| 278 | 278 | { |
| 279 | 279 | $invite = Invite::whereCode($code)->first(); |
| 280 | 280 | |
| 281 | - if(!$invite) |
|
| 281 | + if (!$invite) |
|
| 282 | 282 | throw new InvalidInvitationCodeException; |
| 283 | 283 | |
| 284 | - if($invite->valid_from > now()) |
|
| 284 | + if ($invite->valid_from > now()) |
|
| 285 | 285 | throw new InvitationNotYetActiveException($invite->valid_from); |
| 286 | 286 | |
| 287 | - if($invite->valid_upto && $invite->valid_upto <= now()) |
|
| 287 | + if ($invite->valid_upto && $invite->valid_upto <= now()) |
|
| 288 | 288 | throw new InvitationExpiredException($invite->valid_upto); |
| 289 | 289 | |
| 290 | - if($invite->used_count > ($invite->allowed_count-1)) |
|
| 290 | + if ($invite->used_count > ($invite->allowed_count - 1)) |
|
| 291 | 291 | throw new MaximumUseOfCodeException($invite->allowed_count); |
| 292 | 292 | |
| 293 | - if($invite->email !== $email && !blank($invite->email)) |
|
| 293 | + if ($invite->email !== $email && !blank($invite->email)) |
|
| 294 | 294 | throw new InvitationNotValidWithEmailException($email, $invite->email); |
| 295 | 295 | |
| 296 | 296 | return true; |
@@ -44,10 +44,11 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | public function get() |
| 46 | 46 | { |
| 47 | - if(!blank(optional($this->data)['email'])) |
|
| 48 | - $result = Invite::valid()->whereEmail($this->data['email'])->first(); |
|
| 49 | - else |
|
| 50 | - $result = Invite::valid()->get(); |
|
| 47 | + if(!blank(optional($this->data)['email'])) { |
|
| 48 | + $result = Invite::valid()->whereEmail($this->data['email'])->first(); |
|
| 49 | + } else { |
|
| 50 | + $result = Invite::valid()->get(); |
|
| 51 | + } |
|
| 51 | 52 | |
| 52 | 53 | $this->initializeData(); |
| 53 | 54 | |
@@ -65,8 +66,9 @@ discard block |
||
| 65 | 66 | $validator = Validator::make(compact('email'),[ |
| 66 | 67 | 'email'=>'required|email' |
| 67 | 68 | ]); |
| 68 | - if($validator->fails()) |
|
| 69 | - throw new InvalidEmailIdException; |
|
| 69 | + if($validator->fails()) { |
|
| 70 | + throw new InvalidEmailIdException; |
|
| 71 | + } |
|
| 70 | 72 | |
| 71 | 73 | $this->data['email'] = $email; |
| 72 | 74 | |
@@ -77,8 +79,9 @@ discard block |
||
| 77 | 79 | { |
| 78 | 80 | $invite = Invite::create($this->data); |
| 79 | 81 | |
| 80 | - if($invite->email && config('laravelinvites.mail.enabled', true)) |
|
| 81 | - Mail::to($invite->email)->send(new InvitationMail($invite)); |
|
| 82 | + if($invite->email && config('laravelinvites.mail.enabled', true)) { |
|
| 83 | + Mail::to($invite->email)->send(new InvitationMail($invite)); |
|
| 84 | + } |
|
| 82 | 85 | |
| 83 | 86 | return $invite; |
| 84 | 87 | } |
@@ -97,8 +100,9 @@ discard block |
||
| 97 | 100 | */ |
| 98 | 101 | private function prepare() |
| 99 | 102 | { |
| 100 | - if($this->number_of_invites == 1) |
|
| 101 | - return $this->prepareSingle(); |
|
| 103 | + if($this->number_of_invites == 1) { |
|
| 104 | + return $this->prepareSingle(); |
|
| 105 | + } |
|
| 102 | 106 | |
| 103 | 107 | $invites = []; |
| 104 | 108 | |
@@ -121,15 +125,17 @@ discard block |
||
| 121 | 125 | { |
| 122 | 126 | if(optional($this->data)['email'] && !blank($this->data['email'])) |
| 123 | 127 | { |
| 124 | - if($number_of_invites > 1) |
|
| 125 | - throw new AnEmailCanHaveOnlyOneInvitation; |
|
| 128 | + if($number_of_invites > 1) { |
|
| 129 | + throw new AnEmailCanHaveOnlyOneInvitation; |
|
| 130 | + } |
|
| 126 | 131 | |
| 127 | 132 | $validator = Validator::make($this->data,[ |
| 128 | 133 | 'email'=>'unique:'.config('laravelinvites.table').',email' |
| 129 | 134 | ]); |
| 130 | 135 | |
| 131 | - if($validator->fails()) |
|
| 132 | - throw new AnEmailCanHaveOnlyOneInvitation; |
|
| 136 | + if($validator->fails()) { |
|
| 137 | + throw new AnEmailCanHaveOnlyOneInvitation; |
|
| 138 | + } |
|
| 133 | 139 | } |
| 134 | 140 | |
| 135 | 141 | $this->number_of_invites = $number_of_invites; |
@@ -219,28 +225,23 @@ discard block |
||
| 219 | 225 | |
| 220 | 226 | $this->check($code, $email); |
| 221 | 227 | return true; |
| 222 | - } |
|
| 223 | - catch(InvalidInvitationCodeException $e) |
|
| 228 | + } catch(InvalidInvitationCodeException $e) |
|
| 224 | 229 | { |
| 225 | 230 | $validator->errors()->add($emailFieldName, ':attribute is invalid'); |
| 226 | 231 | return false; |
| 227 | - } |
|
| 228 | - catch(InvitationNotYetActiveException $e) |
|
| 232 | + } catch(InvitationNotYetActiveException $e) |
|
| 229 | 233 | { |
| 230 | 234 | $validator->errors()->add($emailFieldName, ':attribute is not valid yet'); |
| 231 | 235 | return false; |
| 232 | - } |
|
| 233 | - catch(InvitationExpiredException $e) |
|
| 236 | + } catch(InvitationExpiredException $e) |
|
| 234 | 237 | { |
| 235 | 238 | $validator->errors()->add($emailFieldName, ':attribute expired'); |
| 236 | 239 | return false; |
| 237 | - } |
|
| 238 | - catch(InvitationNotValidWithEmailException $e) |
|
| 240 | + } catch(InvitationNotValidWithEmailException $e) |
|
| 239 | 241 | { |
| 240 | 242 | $validator->errors()->add($emailFieldName, ':attribute is not valid with the provided '.$emailFieldName); |
| 241 | 243 | return false; |
| 242 | - } |
|
| 243 | - catch(MaximumUseOfCodeException $e) |
|
| 244 | + } catch(MaximumUseOfCodeException $e) |
|
| 244 | 245 | { |
| 245 | 246 | $validator->errors()->add($emailFieldName, ':attribute has been used for the maximum possible times'); |
| 246 | 247 | return false; |
@@ -261,8 +262,7 @@ discard block |
||
| 261 | 262 | $this->check($code, $email); |
| 262 | 263 | |
| 263 | 264 | return true; |
| 264 | - } |
|
| 265 | - catch(LaravelInvitesException $e) |
|
| 265 | + } catch(LaravelInvitesException $e) |
|
| 266 | 266 | { |
| 267 | 267 | return false; |
| 268 | 268 | } |
@@ -278,20 +278,25 @@ discard block |
||
| 278 | 278 | { |
| 279 | 279 | $invite = Invite::whereCode($code)->first(); |
| 280 | 280 | |
| 281 | - if(!$invite) |
|
| 282 | - throw new InvalidInvitationCodeException; |
|
| 281 | + if(!$invite) { |
|
| 282 | + throw new InvalidInvitationCodeException; |
|
| 283 | + } |
|
| 283 | 284 | |
| 284 | - if($invite->valid_from > now()) |
|
| 285 | - throw new InvitationNotYetActiveException($invite->valid_from); |
|
| 285 | + if($invite->valid_from > now()) { |
|
| 286 | + throw new InvitationNotYetActiveException($invite->valid_from); |
|
| 287 | + } |
|
| 286 | 288 | |
| 287 | - if($invite->valid_upto && $invite->valid_upto <= now()) |
|
| 288 | - throw new InvitationExpiredException($invite->valid_upto); |
|
| 289 | + if($invite->valid_upto && $invite->valid_upto <= now()) { |
|
| 290 | + throw new InvitationExpiredException($invite->valid_upto); |
|
| 291 | + } |
|
| 289 | 292 | |
| 290 | - if($invite->used_count > ($invite->allowed_count-1)) |
|
| 291 | - throw new MaximumUseOfCodeException($invite->allowed_count); |
|
| 293 | + if($invite->used_count > ($invite->allowed_count-1)) { |
|
| 294 | + throw new MaximumUseOfCodeException($invite->allowed_count); |
|
| 295 | + } |
|
| 292 | 296 | |
| 293 | - if($invite->email !== $email && !blank($invite->email)) |
|
| 294 | - throw new InvitationNotValidWithEmailException($email, $invite->email); |
|
| 297 | + if($invite->email !== $email && !blank($invite->email)) { |
|
| 298 | + throw new InvitationNotValidWithEmailException($email, $invite->email); |
|
| 299 | + } |
|
| 295 | 300 | |
| 296 | 301 | return true; |
| 297 | 302 | } |