1. Go to this page and download the library: Download jundayw/laravel-policy 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/ */
jundayw / laravel-policy example snippets
namespace App\Models;
use Jundayw\LaravelPolicy\PolicyContract;
use Jundayw\LaravelPolicy\Policy;
class Manager extends Authenticate implements PolicyContract
{
use Policy;
/**
* @param string $ability
* @param mixed $arguments
* @return string[]
*/
public function getPolicies(string $ability, mixed $arguments): array
{
// do anything for get polices
return [
// "backend.module.list",
// "backend.module.create",
// "backend.module.store",
// "backend.module.edit",
// "backend.module.update",
// "backend.module.destroy",
// "backend.policy.list",
// "backend.policy.create",
// "backend.policy.store",
// "backend.policy.edit",
// "backend.policy.update",
// "backend.policy.destroy",
// "backend.role.*",
// "backend.*.*",
];
}
}
class AuthController extends CommonController
{
public function __construct()
{
$this->middleware('policy');
}
}