37 lines
707 B
PHP
37 lines
707 B
PHP
<?php
|
|
|
|
namespace App\Repositories;
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Database\Eloquent\Collection;
|
|
|
|
class UserRepository extends BaseRepository
|
|
{
|
|
public function __construct(User $model)
|
|
{
|
|
parent::__construct($model);
|
|
}
|
|
|
|
/**
|
|
* Get users by role.
|
|
*
|
|
* @return Collection
|
|
*/
|
|
public function getByRole(string $role)
|
|
{
|
|
return $this->model->role($role)->get();
|
|
}
|
|
|
|
/**
|
|
* Search users by name or email.
|
|
*
|
|
* @return Collection
|
|
*/
|
|
public function search(string $query)
|
|
{
|
|
return $this->model->where('name', 'like', "%{$query}%")
|
|
->orWhere('email', 'like', "%{$query}%")
|
|
->get();
|
|
}
|
|
}
|