New-OMIS/Modules/User/app/Repositories/UserRepository.php
2024-04-10 15:15:24 +05:45

37 lines
671 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);
$user->roles()->attach($role);
return $user;
}
public function update($userId, array $newDetails)
{
return User::whereId($userId)->update($newDetails);
}
}