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

37 lines
671 B
PHP
Raw Permalink 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);
2024-04-10 09:30:24 +00:00
$user->roles()->attach($role);
return $user;
2024-04-07 12:14:05 +00:00
}
public function update($userId, array $newDetails)
{
return User::whereId($userId)->update($newDetails);
}
}