for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace App\Actions;
use App\Models\User;
use App\Models\UserRoles;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Log;
class GetUserRoles
{
public function run(User $user)
$userRole = $user->role_id;
switch($userRole)
case 1:
$roles = UserRoles::all();
break;
case 2:
$roles = UserRoles::where('role_id', '>=', 2)->get();
default:
$roles = UserRoles::where('role_id', '>', 2)->get();
}
return $roles;