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\Exports\MachineExporter;
use App\Filament\Imports\MachineImporter; use App\Filament\Imports\MachineImporter;
use App\Filament\Resources\MachineResource\Pages; use App\Filament\Resources\MachineResource\Pages;
use App\Filament\Resources\MachineResource\RelationManagers;
use App\Models\Line; use App\Models\Line;
use App\Models\Machine; use App\Models\Machine;
use App\Models\Plant; use App\Models\Plant;
@@ -16,11 +15,11 @@ use Filament\Forms\Form;
use Filament\Forms\Get; use Filament\Forms\Get;
use Filament\Resources\Resource; use Filament\Resources\Resource;
use Filament\Tables; use Filament\Tables;
use Filament\Tables\Actions\ExportAction;
use Filament\Tables\Actions\ImportAction;
use Filament\Tables\Table; use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope; use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Tables\Actions\ImportAction;
use Filament\Tables\Actions\ExportAction;
use Illuminate\Validation\Rule; use Illuminate\Validation\Rule;
use Str; use Str;
@@ -45,6 +44,7 @@ class MachineResource extends Resource
->reactive() ->reactive()
->options(function (callable $get) { ->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id; $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::pluck('name', 'id')->toArray();
}) })
->default(function () { ->default(function () {
@@ -57,10 +57,9 @@ class MachineResource extends Resource
$set('mPlantError', 'Please select a plant first.'); $set('mPlantError', 'Please select a plant first.');
$set('line_id', null); $set('line_id', null);
$set('work_group_master_id', null); $set('work_group_master_id', null);
return; return;
} } else {
else
{
$set('mPlantError', null); $set('mPlantError', null);
} }
}) })
@@ -90,10 +89,9 @@ class MachineResource extends Resource
if (! $lineId) { if (! $lineId) {
$set('mLineError', 'Please select a line first.'); $set('mLineError', 'Please select a line first.');
$set('work_group_master_id', null); $set('work_group_master_id', null);
return; return;
} } else {
else
{
// $grpWrkCnr = Line::find($lineId)->group_work_center; // $grpWrkCnr = Line::find($lineId)->group_work_center;
// if (!$grpWrkCnr || Str::length($grpWrkCnr) < 1) // if (!$grpWrkCnr || Str::length($grpWrkCnr) < 1)
// { // {
@@ -138,10 +136,9 @@ class MachineResource extends Resource
$lineId = $get('line_id'); $lineId = $get('line_id');
if (! $lineId) { if (! $lineId) {
$set('mGroupWorkError', 'Please select a line first.'); $set('mGroupWorkError', 'Please select a line first.');
return; return;
} } else {
else
{
// $grpWrkCnr = Line::find($lineId)->group_work_center; // $grpWrkCnr = Line::find($lineId)->group_work_center;
// if (!$grpWrkCnr || Str::length($grpWrkCnr) < 1) // if (!$grpWrkCnr || Str::length($grpWrkCnr) < 1)
// { // {
@@ -194,6 +191,7 @@ class MachineResource extends Resource
$paginator = $livewire->getTableRecords(); $paginator = $livewire->getTableRecords();
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10; $perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1; $currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
return ($currentPage - 1) * $perPage + $rowLoop->iteration; return ($currentPage - 1) * $perPage + $rowLoop->iteration;
}), }),
Tables\Columns\TextColumn::make('plant.name') Tables\Columns\TextColumn::make('plant.name')