New-OMIS/Modules/User/app/Repositories/UserRepository.php

36 lines
656 B
PHP
Raw Normal View History

2024-04-07 12:14:05 +00:00
<?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);
}
}