-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(roles): 数据模型增加 description 和通用字段
- Loading branch information
1 parent
ae2f9ce
commit b755f0a
Showing
8 changed files
with
231 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\SoftDeletes; | ||
use Spatie\Permission\Models\Role as SpatieRole; | ||
|
||
/** | ||
* @mixin IdeHelperRole | ||
*/ | ||
class Role extends SpatieRole | ||
{ | ||
use SoftDeletes; | ||
|
||
/** | ||
* The attributes that are mass assignable. | ||
* | ||
* @var list<string> | ||
*/ | ||
protected $fillable = [ | ||
'name', | ||
'guard_name', | ||
'description', | ||
'state', | ||
'order', | ||
]; | ||
|
||
/** | ||
* Get the attributes that should be cast. | ||
* | ||
* @return array<string,string> | ||
*/ | ||
protected function casts(): array | ||
{ | ||
return [ | ||
'state' => 'boolean', | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
database/migrations/2024_12_12_145534_add_description_to_roles_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
Schema::table('roles', function (Blueprint $table) { | ||
$table->string('description')->nullable(); | ||
$table->boolean('state')->default(true)->comment('状态'); | ||
$table->unsignedInteger('order')->default(0)->comment('排序'); | ||
$table->softDeletesTz(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::table('roles', function (Blueprint $table) { | ||
$table->dropColumn(['description', 'state', 'order', 'deleted_at']); | ||
}); | ||
} | ||
}; |