class EloquentUserRepository implements UserRepositoryInterface
{
protected $model;
public function __construct(User $model)
{
$this->model = $model;
}
public function find($id)
{
return $this->model->findOrFail($id);
}
public function create(array $data)
{
return $this->model->create($data);
}
public function update($id, array $data)
{
$user = $this->find($id);
$user->update($data);
return $user;
}
public function delete($id)
{
return $this->model->destroy($id);
}
}
class EloquentUserRepository implements UserRepositoryInterface
{
protected $model;
public function __construct(User $model)
{
$this->model = $model;
}
public function find($id)
{
return $this->model->findOrFail($id);
}
public function create(array $data)
{
return $this->model->create($data);
}
public function update($id, array $data)
{
$user = $this->find($id);
$user->update($data);
return $user;
}
public function delete($id)
{
return $this->model->destroy($id);
}
}