<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\User;
use Spatie\Permission\Models\Role;

class AdminRoleController extends Controller
{
    public function index()
    {
        //dd('Debugging');
        $users = User::all();
        $roles = Role::all();
        return view('admin.roles.index', compact('users', 'roles'));
    }
    
    public function assignRole(Request $request, User $user)
    {
        $user->syncRoles($request->roles);
        return redirect()->back()->with('success', 'Roles asignados correctamente.');
    }
}
