1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Humweb\Sociable\Models; |
4
|
|
|
|
5
|
|
|
use Illuminate\Database\Eloquent\Model; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class SocialAuth |
9
|
|
|
* |
10
|
|
|
* @package Humweb\SociableConnection\Models |
11
|
|
|
*/ |
12
|
|
|
class SocialConnection extends Model |
13
|
|
|
{ |
14
|
|
|
|
15
|
|
|
protected $table = 'social_connections'; |
16
|
|
|
|
17
|
|
|
protected $fillable = ['provider', 'user_id', 'social_id', 'oauth_version', 'data']; |
18
|
|
|
|
19
|
|
|
protected $casts = [ |
20
|
|
|
'data' => 'json' |
21
|
|
|
]; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* The users model name. |
25
|
|
|
* |
26
|
|
|
* @var string |
27
|
|
|
*/ |
28
|
|
|
protected static $userModel = 'LGL\Core\Auth\Users\EloquentUser'; |
29
|
|
|
|
30
|
|
|
|
31
|
3 |
|
public function user() |
32
|
|
|
{ |
33
|
3 |
|
return $this->belongsTo(static::$userModel, 'user_id'); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
|
37
|
3 |
|
public function scopeOfProvider($query, $provider) |
38
|
|
|
{ |
39
|
3 |
|
return is_array($provider) ? $query->whereIn('provider', $provider) : $query->where('provider', $provider); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
|
43
|
3 |
|
public function scopeOfProviderId($query, $socialId) |
44
|
|
|
{ |
45
|
3 |
|
return is_array($socialId) ? $query->whereIn('social_id', $socialId) : $query->where('social_id', $socialId); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
|
49
|
3 |
|
public function scopeOfCredentials($query, $provider, $socialId) |
50
|
|
|
{ |
51
|
3 |
|
return $query->where('provider', $provider)->where('social_id', $socialId); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
|
55
|
3 |
|
public function getUser() |
56
|
|
|
{ |
57
|
3 |
|
return $this->user; |
|
|
|
|
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @param $user |
63
|
|
|
*/ |
64
|
3 |
|
public function setUser($user) |
65
|
|
|
{ |
66
|
3 |
|
$this->user()->associate($user); |
67
|
|
|
|
68
|
3 |
|
$this->save(); |
69
|
3 |
|
} |
70
|
|
|
|
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Get the users model. |
74
|
|
|
* |
75
|
|
|
* @return string |
76
|
|
|
*/ |
77
|
3 |
|
public static function getUsersModel() |
78
|
|
|
{ |
79
|
3 |
|
return static::$userModel; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Set the users model. |
85
|
|
|
* |
86
|
|
|
* @param string $usersModel |
87
|
|
|
* |
88
|
|
|
* @return void |
89
|
|
|
*/ |
90
|
27 |
|
public static function setUsersModel($usersModel) |
91
|
|
|
{ |
92
|
27 |
|
static::$userModel = $usersModel; |
93
|
27 |
|
} |
94
|
|
|
|
95
|
|
|
} |
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.