BlogEtcAuthGateNotImplementedException   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 5
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 2
c 1
b 0
f 0
dl 0
loc 5
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
1
<?php
2
3
namespace WebDevEtc\BlogEtc\Exceptions;
4
5
use Illuminate\Database\Eloquent\ModelNotFoundException;
6
use Throwable;
7
8
class BlogEtcAuthGateNotImplementedException extends ModelNotFoundException
9
{
10
    public function __construct($_ = '', $code = 0, Throwable $previous = null)
11
    {
12
        parent::__construct('You must implement your own gate in AuthServiceProvider for the \WebDevEtc\BlogEtc\Gates\GateTypes::MANAGE_ADMIN gate.', $code, $previous);
13
14
        // Add something like the following to AuthServiceProvider:
15
16
        //  Gate::define(GateTypes::MANAGE_BLOG_ADMIN, static function (?Model $user) {
17
        //      Implement your logic to allow or disallow admin access for $user
18
        //      return $model->is_admin === true;
19
        //      or:
20
        //      return $model->email === '[email protected]';
21
        //  });
22
    }
23
}
24