From 7451d5f99ce72197cb7b6f13b4371c15aa1542a8 Mon Sep 17 00:00:00 2001 From: Steve <34465153+xxl4@users.noreply.github.com> Date: Fri, 6 Sep 2024 13:45:00 +0800 Subject: [PATCH] #11 apis v2 model --- .../2024_09_01_000000_create_rules_table.php | 2 ++ ..._09_03_034032_create_permissions_table.php | 3 ++ .../2024_09_06_025419_create_roles_table.php | 2 ++ src/Models/Admin.php | 35 +++++++++++++++++++ src/Models/Permission.php | 18 ++++++++++ src/Models/Role.php | 18 ++++++++++ 6 files changed, 78 insertions(+) create mode 100644 src/Models/Admin.php create mode 100644 src/Models/Permission.php create mode 100644 src/Models/Role.php diff --git a/src/Database/Migrations/2024_09_01_000000_create_rules_table.php b/src/Database/Migrations/2024_09_01_000000_create_rules_table.php index f854671..000ad27 100644 --- a/src/Database/Migrations/2024_09_01_000000_create_rules_table.php +++ b/src/Database/Migrations/2024_09_01_000000_create_rules_table.php @@ -22,6 +22,8 @@ public function up() $table->string('v4')->nullable(); $table->string('v5')->nullable(); $table->timestamps(); + + $table->comment('casbin rule table'); }); } diff --git a/src/Database/Migrations/2024_09_03_034032_create_permissions_table.php b/src/Database/Migrations/2024_09_03_034032_create_permissions_table.php index fc4de73..a2cbdda 100644 --- a/src/Database/Migrations/2024_09_03_034032_create_permissions_table.php +++ b/src/Database/Migrations/2024_09_03_034032_create_permissions_table.php @@ -30,6 +30,9 @@ public function up() $table->unsignedTinyInteger('type')->default(0); $table->unsignedTinyInteger('status')->default(1); $table->timestamps(); + + + $table->comment('permission table'); }); } diff --git a/src/Database/Migrations/2024_09_06_025419_create_roles_table.php b/src/Database/Migrations/2024_09_06_025419_create_roles_table.php index b059f04..98c1466 100644 --- a/src/Database/Migrations/2024_09_06_025419_create_roles_table.php +++ b/src/Database/Migrations/2024_09_06_025419_create_roles_table.php @@ -20,6 +20,8 @@ public function up() $table->string('desc')->nullable(); $table->unsignedTinyInteger('status')->default(1); $table->timestamps(); + + $table->comment('role table'); }); } diff --git a/src/Models/Admin.php b/src/Models/Admin.php new file mode 100644 index 0000000..8bfb215 --- /dev/null +++ b/src/Models/Admin.php @@ -0,0 +1,35 @@ +getKey(); + } + + public function getJWTCustomClaims() + { + return []; + } + + protected $casts = [ + 'id' => 'string', + 'created_at' => 'datetime:Y-m-d H:i:s', + 'updated_at' => 'datetime:Y-m-d H:i:s', + ]; +} diff --git a/src/Models/Permission.php b/src/Models/Permission.php new file mode 100644 index 0000000..0b5218a --- /dev/null +++ b/src/Models/Permission.php @@ -0,0 +1,18 @@ + 'string', + 'created_at' => 'datetime:Y-m-d H:i:s', + 'updated_at' => 'datetime:Y-m-d H:i:s', + ]; +} diff --git a/src/Models/Role.php b/src/Models/Role.php new file mode 100644 index 0000000..32e08fc --- /dev/null +++ b/src/Models/Role.php @@ -0,0 +1,18 @@ + 'string', + 'created_at' => 'datetime:Y-m-d H:i:s', + 'updated_at' => 'datetime:Y-m-d H:i:s', + ]; +}