feat: add app and database modules
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user