Updated alignment on resource
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s

This commit is contained in:
dhanabalan
2026-01-14 09:06:45 +05:30
parent 13912de584
commit a0a10cb668

View File

@@ -5,7 +5,6 @@ namespace App\Filament\Resources;
use App\Filament\Exports\MachineExporter;
use App\Filament\Imports\MachineImporter;
use App\Filament\Resources\MachineResource\Pages;
use App\Filament\Resources\MachineResource\RelationManagers;
use App\Models\Line;
use App\Models\Machine;
use App\Models\Plant;
@@ -16,11 +15,11 @@ use Filament\Forms\Form;
use Filament\Forms\Get;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Actions\ExportAction;
use Filament\Tables\Actions\ImportAction;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Tables\Actions\ImportAction;
use Filament\Tables\Actions\ExportAction;
use Illuminate\Validation\Rule;
use Str;
@@ -45,22 +44,22 @@ class MachineResource 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();
})
->default(function () {
return optional(Machine::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('mPlantError', 'Please select a plant first.');
$set('line_id', null);
$set('work_group_master_id', null);
return;
}
else
{
} else {
$set('mPlantError', null);
}
})
@@ -75,7 +74,7 @@ class MachineResource extends Resource
->required()
->reactive()
->options(function (callable $get) {
if (!$get('plant_id')) {
if (! $get('plant_id')) {
return [];
}
@@ -84,16 +83,15 @@ class MachineResource extends Resource
->default(function () {
return optional(Machine::latest()->first())->line_id;
})
->disabled(fn (Get $get) => !empty($get('id')))
->disabled(fn (Get $get) => ! empty($get('id')))
->afterStateUpdated(function ($state, callable $set, callable $get) {
$lineId = $get('line_id');
if (!$lineId) {
if (! $lineId) {
$set('mLineError', 'Please select a line first.');
$set('work_group_master_id', null);
return;
}
else
{
} else {
// $grpWrkCnr = Line::find($lineId)->group_work_center;
// if (!$grpWrkCnr || Str::length($grpWrkCnr) < 1)
// {
@@ -115,7 +113,7 @@ class MachineResource extends Resource
->required()
->reactive()
->options(function (callable $get) {
if (!$get('plant_id') || !$get('line_id')) {
if (! $get('plant_id') || ! $get('line_id')) {
return [];
}
@@ -123,7 +121,7 @@ class MachineResource extends Resource
$workGroupIds = [];
for ($i = 1; $i <= $line->no_of_operation; $i++) {
$column = "work_group{$i}_id";
if (!empty($line->$column)) {
if (! empty($line->$column)) {
$workGroupIds[] = $line->$column;
}
}
@@ -133,15 +131,14 @@ class MachineResource extends Resource
->default(function () {
return optional(Machine::latest()->first())->work_group_master_id;
})
->disabled(fn (Get $get) => !empty($get('id')))
->disabled(fn (Get $get) => ! empty($get('id')))
->afterStateUpdated(function ($state, callable $set, callable $get) {
$lineId = $get('line_id');
if (!$lineId) {
if (! $lineId) {
$set('mGroupWorkError', 'Please select a line first.');
return;
}
else
{
} else {
// $grpWrkCnr = Line::find($lineId)->group_work_center;
// if (!$grpWrkCnr || Str::length($grpWrkCnr) < 1)
// {
@@ -164,7 +161,7 @@ class MachineResource extends Resource
->required()
->rule(function (callable $get) {
return Rule::unique('machines', 'name')
//->where('line_id', $get('line_id'))
// ->where('line_id', $get('line_id'))
->where('plant_id', $get('plant_id'))
->ignore($get('id')); // Ignore current record during updates
}),
@@ -194,6 +191,7 @@ class MachineResource 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('plant.name')
@@ -254,14 +252,14 @@ class MachineResource extends Resource
->label('Import Machines')
->color('warning')
->importer(MachineImporter::class)
->visible(function() {
->visible(function () {
return Filament::auth()->user()->can('view import machine');
}),
ExportAction::make()
->label('Export Machines')
->color('warning')
->exporter(MachineExporter::class)
->visible(function() {
->visible(function () {
return Filament::auth()->user()->can('view export machine');
}),
]);