first commit

This commit is contained in:
Sampanna Rimal
2024-08-27 17:48:06 +05:45
commit 53c0140f58
10839 changed files with 1125847 additions and 0 deletions

View File

@ -0,0 +1,40 @@
<?php
namespace Modules\User\Repositories;
use App\Models\User;
class UserRepository implements UserInterface
{
public function findAll()
{
return User::with(['employee.department'])->get();
}
public function getUserById($userId)
{
return User::findOrFail($userId);
}
public function create(array $userDetails, array $role)
{
$user = User::create($userDetails);
$user->roles()->attach($role);
return $user;
}
public function update($userId, array $newDetails, array $role)
{
$user = User::whereId($userId)->update($newDetails);
$user->roles()->sync($role);
return $user;
}
public function delete($userId)
{
$user = User::whereId($userId)->first();
$user->roles()->detach();
return $user->destroy();
}
}