三表:用户表、角色表、权限表
角色表:role
权限表:auth
1、创建需要迁移文件
php artisan make:migration create_role_table
php artisan make:migration create_auth_table
2、迁移代码
2020_04_05_003842_create_role_table.php
<?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; class CreateRoleTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create(‘role‘, function (Blueprint $table) { $table->increments(‘id‘); $table->string(‘role_name‘,20)->notNull(); $table->text(‘auth_ids‘); $table->text(‘auth_ac‘); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists(‘role‘); } }
2020_04_05_003854_create_auth_table.php
②执行迁移文件生成数据表
php artisan migrate
3 确定需要的路由
添加页面:/admin/auth/add any类型
列表页面:/admin/auth/index get类型
4 创建需要的控制器文件
php artisan make:controller Admin/AuthController
5 创建2个方法,Auth控制器下的index方法、add方法,展示各自的视图即可
原文:https://www.cnblogs.com/linzenews/p/12635568.html