36 lines
656 B
PHP
36 lines
656 B
PHP
<?php
|
|
|
|
namespace Modules\User\Repositories;
|
|
|
|
use App\Models\User;
|
|
|
|
class UserRepository implements UserInterface
|
|
{
|
|
public function findAll()
|
|
{
|
|
return User::get();
|
|
}
|
|
|
|
public function getUserById($userId)
|
|
{
|
|
return User::findOrFail($userId);
|
|
}
|
|
|
|
public function delete($userId)
|
|
{
|
|
User::destroy($userId);
|
|
}
|
|
|
|
public function create(array $userDetails, array $role)
|
|
{
|
|
$user = User::create($userDetails);
|
|
return $user->roles()->attach($role);
|
|
}
|
|
|
|
public function update($userId, array $newDetails)
|
|
{
|
|
return User::whereId($userId)->update($newDetails);
|
|
}
|
|
|
|
}
|