Created
April 9, 2019 23:23
-
-
Save orobogenius/58080755b47a2d66b2c8023fc939cc42 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Repositories; | |
use App\User; | |
class UserRepository | |
{ | |
/** | |
* @var \Illuminate\Database\Eloquent\Model | |
*/ | |
protected $model; | |
/** | |
* Create a new user repository instance. | |
* | |
* @param \App\User | |
*/ | |
public function __construct(User $model) | |
{ | |
$this->model = $model; | |
} | |
/** | |
* Retrieve or create a new resource owner. | |
* | |
* @param array $attributes | |
* @return App\User | |
*/ | |
public function findOrCreateSocialUser(array $attributes) | |
{ | |
return $this->model->firstOrCreate( | |
['provider_id' => $attributes['id']], | |
$attributes | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment