Updated alignments and added orderby query while load plant
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled

This commit is contained in:
dhanabalan
2026-02-10 12:45:54 +05:30
parent 6c9408663b
commit aaa9c17e66
36 changed files with 1592 additions and 1574 deletions

View File

@@ -5,7 +5,6 @@ namespace App\Filament\Resources;
use App\Filament\Exports\GuardNameExporter;
use App\Filament\Imports\GuardNameImporter;
use App\Filament\Resources\GuardNameResource\Pages;
use App\Filament\Resources\GuardNameResource\RelationManagers;
use App\Models\GuardName;
use App\Models\Plant;
use Filament\Facades\Filament;
@@ -42,20 +41,20 @@ class GuardNameResource extends Resource
->reactive()
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->default(function () {
return optional(GuardName::latest()->first())->plant_id;
})
->disabled(fn (Get $get) => !empty($get('id')))
->disabled(fn (Get $get) => ! empty($get('id')))
->afterStateUpdated(function ($state, callable $set, callable $get) {
$plantId = $get('plant_id');
if (!$plantId) {
if (! $plantId) {
$set('GnError', 'Please select a plant first.');
return;
}
else
{
} else {
$set('GnError', null);
$set('created_by', Filament::auth()->user()?->name);
}
@@ -113,6 +112,7 @@ class GuardNameResource extends Resource
$paginator = $livewire->getTableRecords();
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
}),
// Tables\Columns\TextColumn::make('id')
@@ -169,14 +169,14 @@ class GuardNameResource extends Resource
->label('Import Guard Names')
->color('warning')
->importer(GuardNameImporter::class)
->visible(function() {
->visible(function () {
return Filament::auth()->user()->can('view import guard name');
}),
ExportAction::make()
->label('Export Guard Names')
->color('warning')
->exporter(GuardNameExporter::class)
->visible(function() {
->visible(function () {
return Filament::auth()->user()->can('view export guard name');
}),
]);