1. Go to this page and download the library: Download haojohnny/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/ */
haojohnny / permission example snippets
use Haojohnny\Permission\Models\Roles;
use Haojohnny\Permission\Models\Permissions;
$role = Roles::create(['name' => 'editor']);
$permission = Permissions::create(['name' => 'edit articles']);
use Haojohnny\Permission\Models\Roles;
use Haojohnny\Permission\Models\Permissions;
$role = Roles::findOrCreate(['name' => 'editor']);
$permission = Permissions::findOrCreate(['name' => 'permission1']);
namespace app\index\model;
use think\Model;
use Haojohnny\Permission\Traits\HasRoles;
class User extends Model
{
use HasRoles;
// ...
}