datatable.directory codebase
https://datatable.directory/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
733 B
35 lines
733 B
<?php namespace AdamWathan\EloquentOAuth;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class UserStore
|
|
{
|
|
/** @var string */
|
|
protected $modelClass;
|
|
|
|
public function __construct(string $modelClass)
|
|
{
|
|
$this->modelClass = $modelClass;
|
|
}
|
|
|
|
public function create()
|
|
{
|
|
$user = new $this->modelClass;
|
|
return $user;
|
|
}
|
|
|
|
public function store(Model $user)
|
|
{
|
|
return $user->save();
|
|
}
|
|
|
|
public function findByIdentity(OAuthIdentity $identity)
|
|
{
|
|
return $identity->belongsTo($this->modelClass, 'user_id')->firstOrFail();
|
|
}
|
|
|
|
public function findByEmail(string $email)
|
|
{
|
|
return $this->modelClass::where('email', $email)->firstOrFail();
|
|
}
|
|
}
|
|
|