PHP code example of adityaricki / laravel-permission
1. Go to this page and download the library: Download adityaricki/laravel-permission library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// Attach 1 route into user
$user->routes()->attach($routeId);
// Attach multiple routes into user
$user->routes()->attach([$routeId1, $routeId2, $routeId3, ...]);
// Detach 1 route from user
$user->routes()->detach($routeId);
// Detach multiple routes from user
$user->routes()->detach([$routeId1, $routeId2, $routeId3, ...]);
// Sync routes to user
$user->routes()->sync([$routeId1, $routeId2, $routeId3, ...]);
// Sync routes to user without detaching
$user->routes()->syncWithoutDetaching([$routeId1, $routeId2, $routeId3, ...]);