Skip to content

Instantly share code, notes, and snippets.

@orobogenius
Created April 9, 2019 23:23
Show Gist options
  • Save orobogenius/58080755b47a2d66b2c8023fc939cc42 to your computer and use it in GitHub Desktop.
Save orobogenius/58080755b47a2d66b2c8023fc939cc42 to your computer and use it in GitHub Desktop.
<?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