Skip to content

Commit

Permalink
refactor(admin & role): rename order field to sort
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaiyuxin103 committed Dec 17, 2024
1 parent 525929c commit dbdf0cb
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 20 deletions.
9 changes: 4 additions & 5 deletions _ide_helper_models.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class IdeHelperAbout {}
* @property string|null $last_actived_at 最后活跃时间
* @property string|null $remember_token
* @property bool $state 状态
* @property int $order 排序
* @property int $sort 排序
* @property \Illuminate\Support\Carbon|null $deleted_at
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
Expand Down Expand Up @@ -117,10 +117,10 @@ class IdeHelperAbout {}
* @method static \Illuminate\Database\Eloquent\Builder|Admin whereLastAuthedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|Admin whereLastName($value)
* @method static \Illuminate\Database\Eloquent\Builder|Admin whereNotificationCount($value)
* @method static \Illuminate\Database\Eloquent\Builder|Admin whereOrder($value)
* @method static \Illuminate\Database\Eloquent\Builder|Admin wherePassword($value)
* @method static \Illuminate\Database\Eloquent\Builder|Admin wherePhone($value)
* @method static \Illuminate\Database\Eloquent\Builder|Admin whereRememberToken($value)
* @method static \Illuminate\Database\Eloquent\Builder|Admin whereSort($value)
* @method static \Illuminate\Database\Eloquent\Builder|Admin whereState($value)
* @method static \Illuminate\Database\Eloquent\Builder|Admin whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|Admin withTrashed()
Expand Down Expand Up @@ -339,7 +339,7 @@ class IdeHelperPrivacy {}
* @property \Illuminate\Support\Carbon|null $updated_at
* @property string|null $description
* @property bool $state 状态
* @property int $order 排序
* @property int $sort 排序
* @property \Illuminate\Support\Carbon|null $deleted_at
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Spatie\Permission\Models\Permission> $permissions
* @property-read int|null $permissions_count
Expand All @@ -356,7 +356,7 @@ class IdeHelperPrivacy {}
* @method static \Illuminate\Database\Eloquent\Builder|Role whereGuardName($value)
* @method static \Illuminate\Database\Eloquent\Builder|Role whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|Role whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|Role whereOrder($value)
* @method static \Illuminate\Database\Eloquent\Builder|Role whereSort($value)
* @method static \Illuminate\Database\Eloquent\Builder|Role whereState($value)
* @method static \Illuminate\Database\Eloquent\Builder|Role whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|Role withTrashed()
Expand Down Expand Up @@ -564,7 +564,6 @@ class IdeHelperUser {}
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property \Illuminate\Support\Carbon|null $deleted_at
* @property-read \App\Models\User|null $user
* @method static \Illuminate\Database\Eloquent\Builder|VerificationCode newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|VerificationCode newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|VerificationCode onlyTrashed()
Expand Down
8 changes: 4 additions & 4 deletions app/Filament/Resources/AdminResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ public static function form(Form $form): Form
->required()
->default(true)
->label(trans('fields.state')),
Forms\Components\TextInput::make('order')
Forms\Components\TextInput::make('sort')
->required()
->numeric()
->default(0)
->label(trans('fields.order')),
->label(trans('fields.sort')),
]),
Forms\Components\Placeholder::make('created_at')
->content(fn (?Admin $record): string => $record?->created_at?->diffForHumans() ?? '-')
Expand Down Expand Up @@ -182,10 +182,10 @@ public static function table(Table $table): Table
Tables\Columns\IconColumn::make('state')
->boolean()
->label(trans('fields.state')),
Tables\Columns\TextColumn::make('order')
Tables\Columns\TextColumn::make('sort')
->numeric()
->sortable()
->label(trans('fields.order')),
->label(trans('fields.sort')),
Tables\Columns\TextColumn::make('created_at')
->dateTime()
->sortable()
Expand Down
6 changes: 3 additions & 3 deletions app/Filament/Resources/Shield/RoleResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static function form(Form $form): Form
->required()
->default(true)
->label(trans('fields.state')),
Forms\Components\TextInput::make('order')
Forms\Components\TextInput::make('sort')
->required()
->numeric()
->default(0)
Expand Down Expand Up @@ -131,10 +131,10 @@ public static function table(Table $table): Table
Tables\Columns\IconColumn::make('state')
->boolean()
->label(trans('fields.state')),
Tables\Columns\TextColumn::make('order')
Tables\Columns\TextColumn::make('sort')
->numeric()
->sortable()
->label(trans('fields.order')),
->label(trans('fields.sort')),
Tables\Columns\TextColumn::make('created_at')
->dateTime()
->sortable()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected function mutateFormDataBeforeCreate(array $data): array
->flatten()
->unique();

return Arr::only($data, ['name', 'guard_name', 'description', 'state', 'order']);
return Arr::only($data, ['name', 'guard_name', 'description', 'state', 'sort']);
}

protected function afterCreate(): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected function mutateFormDataBeforeSave(array $data): array
->flatten()
->unique();

return Arr::only($data, ['name', 'guard_name', 'description', 'state', 'order']);
return Arr::only($data, ['name', 'guard_name', 'description', 'state', 'sort']);
}

protected function afterSave(): void
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Admin extends Authenticatable implements FilamentUser, HasAvatar, HasName
'age',
'introduction',
'state',
'order',
'sort',
];

public function canAccessPanel(Panel $panel): bool
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Role extends SpatieRole
'guard_name',
'description',
'state',
'order',
'sort',
];

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Policies/RolePolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
namespace App\Policies;

use App\Models\Admin;
use App\Models\Role;
use Illuminate\Auth\Access\HandlesAuthorization;
use Spatie\Permission\Models\Role;

class RolePolicy
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function up(): void
$table->timestamp('last_actived_at')->nullable()->comment('最后活跃时间');
$table->rememberToken();
$table->boolean('state')->default(true)->comment('状态');
$table->unsignedBigInteger('order')->default(0)->comment('排序');
$table->unsignedBigInteger('sort')->default(0)->comment('排序');
$table->softDeletesTz();
$table->timestampsTz();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ 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->unsignedInteger('sort')->default(0)->comment('排序');
$table->softDeletesTz();
});
}
Expand All @@ -27,7 +27,7 @@ public function up(): void
public function down(): void
{
Schema::table('roles', function (Blueprint $table) {
$table->dropColumn(['description', 'state', 'order', 'deleted_at']);
$table->dropColumn(['description', 'state', 'sort', 'deleted_at']);
});
}
};

0 comments on commit dbdf0cb

Please sign in to comment.