- Created ExampleTest and RoutesTest for basic application response and route testing. - Implemented IsolatedDatabaseTestCase for isolated database testing. - Added unit tests for various models and services including Contract, CPE, and LeadDetail. - Developed request validation tests for CreateClientRequest, UpdateClientRequest, and ContractRequest. - Introduced Vite configuration for asset management in the Laravel application.
26 lines
647 B
PHP
26 lines
647 B
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Spatie\Permission\Models\Role;
|
|
use Spatie\Permission\Models\Permission;
|
|
|
|
class RolePermissionService
|
|
{
|
|
public function index()
|
|
{
|
|
return [
|
|
'roles' => Role::with('permissions')->get(),
|
|
'permissions' => Permission::all(),
|
|
];
|
|
}
|
|
|
|
public function updatePermissions(Request $request, Role $role)
|
|
{
|
|
$request->validate(['permissions' => 'sometimes|array', 'permissions.*' => 'exists:permissions,name']);
|
|
$role->syncPermissions($request->input('permissions', []));
|
|
return $role->load('permissions');
|
|
}
|
|
}
|