|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace MadWeb\SocialAuth\Models; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Database\Eloquent\Model; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Class SocialProvider. |
|
9
|
|
|
* |
|
10
|
|
|
* @property int $id |
|
11
|
|
|
* @param string $slug |
|
12
|
|
|
* @param string $label |
|
13
|
|
|
* @property string $label |
|
14
|
|
|
* @property string $slug |
|
15
|
|
|
* @property array $scopes |
|
16
|
|
|
* @property array $parameters |
|
17
|
|
|
* @property bool $override_scopes |
|
18
|
|
|
* @property bool $stateless |
|
19
|
|
|
* @property string $created_at |
|
20
|
|
|
* @property string $updated_at |
|
21
|
|
|
* @property-read \Illuminate\Database\Eloquent\Collection|\App\User[] $users |
|
22
|
|
|
* @method static \Illuminate\Database\Query\Builder|\MadWeb\SocialAuth\Models\SocialProvider whereId($value) |
|
23
|
|
|
* @method static \Illuminate\Database\Query\Builder|\MadWeb\SocialAuth\Models\SocialProvider whereLabel($value) |
|
24
|
|
|
* @method static \Illuminate\Database\Query\Builder|\MadWeb\SocialAuth\Models\SocialProvider whereSlug($value) |
|
25
|
|
|
* @method static \Illuminate\Database\Query\Builder|\MadWeb\SocialAuth\Models\SocialProvider whereCreatedAt($value) |
|
26
|
|
|
* @method static \Illuminate\Database\Query\Builder|\MadWeb\SocialAuth\Models\SocialProvider whereUpdatedAt($value) |
|
27
|
|
|
* @mixin \Eloquent |
|
28
|
|
|
*/ |
|
29
|
|
|
class SocialProvider extends Model |
|
30
|
|
|
{ |
|
31
|
|
|
/** |
|
32
|
|
|
* {@inheritdoc} |
|
33
|
|
|
*/ |
|
34
|
|
|
protected $fillable = [ |
|
35
|
|
|
'slug', |
|
36
|
|
|
'label', |
|
37
|
|
|
'scopes', |
|
38
|
|
|
'parameters', |
|
39
|
|
|
'override_scopes', |
|
40
|
|
|
'stateless', |
|
41
|
|
|
]; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* {@inheritdoc} |
|
45
|
|
|
*/ |
|
46
|
|
|
protected $casts = [ |
|
47
|
|
|
'scopes' => 'array', |
|
48
|
|
|
'parameters' => 'array', |
|
49
|
|
|
]; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* SocialProvider constructor. |
|
53
|
|
|
* |
|
54
|
|
|
* @param array $attributes |
|
55
|
|
|
*/ |
|
56
|
57 |
|
public function __construct(array $attributes = []) |
|
57
|
|
|
{ |
|
58
|
57 |
|
parent::__construct($attributes); |
|
59
|
|
|
|
|
60
|
57 |
|
$this->setTable(config('social-auth.table_names.social_providers')); |
|
61
|
57 |
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Get the route key for the model. |
|
65
|
|
|
* |
|
66
|
|
|
* @return string |
|
67
|
|
|
*/ |
|
68
|
48 |
|
public function getRouteKeyName() |
|
69
|
|
|
{ |
|
70
|
48 |
|
return 'slug'; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* Set scopes which will be add to the social auth request. |
|
75
|
|
|
*/ |
|
76
|
|
|
public function setScopes(array $scopes, bool $isOverride = false) |
|
77
|
|
|
{ |
|
78
|
|
|
$this->scopes = $scopes; |
|
79
|
|
|
$this->override_scopes = $isOverride; |
|
80
|
|
|
|
|
81
|
|
|
$this->save(); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
|
86
|
|
|
*/ |
|
87
|
24 |
|
public function users() |
|
88
|
|
|
{ |
|
89
|
24 |
|
return $this->belongsToMany( |
|
90
|
24 |
|
config('social-auth.models.user'), |
|
91
|
24 |
|
config('social-auth.table_names.user_has_social_provider') |
|
92
|
|
|
); |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|