Added not in stock resource pages #456
263
app/Filament/Resources/NotInStockResource.php
Normal file
263
app/Filament/Resources/NotInStockResource.php
Normal file
@@ -0,0 +1,263 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources;
|
||||||
|
|
||||||
|
use App\Filament\Resources\NotInStockResource\Pages;
|
||||||
|
use App\Filament\Resources\NotInStockResource\RelationManagers;
|
||||||
|
use App\Models\NotInStock;
|
||||||
|
use App\Models\StickerMaster;
|
||||||
|
use Filament\Facades\Filament;
|
||||||
|
use Filament\Forms;
|
||||||
|
use Filament\Forms\Form;
|
||||||
|
use Filament\Resources\Resource;
|
||||||
|
use Filament\Tables;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
|
|
||||||
|
class NotInStockResource extends Resource
|
||||||
|
{
|
||||||
|
protected static ?string $model = NotInStock::class;
|
||||||
|
|
||||||
|
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||||
|
|
||||||
|
protected static ?string $navigationGroup = 'Cycle Count Software';
|
||||||
|
|
||||||
|
public static function form(Form $form): Form
|
||||||
|
{
|
||||||
|
return $form
|
||||||
|
->schema([
|
||||||
|
Forms\Components\Select::make('plant_id')
|
||||||
|
->label('Plant')
|
||||||
|
->reactive()
|
||||||
|
->relationship('plant', 'name')
|
||||||
|
->required(),
|
||||||
|
Forms\Components\Select::make('sticker_master_id')
|
||||||
|
->label('Item Code')
|
||||||
|
->reactive()
|
||||||
|
->required()
|
||||||
|
->searchable()
|
||||||
|
->options(function ($get) {
|
||||||
|
if (!$get('plant_id')) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return StickerMaster::with('item')
|
||||||
|
->where('plant_id', $get('plant_id'))
|
||||||
|
->get()
|
||||||
|
->pluck('item.code', 'id')
|
||||||
|
->toArray();
|
||||||
|
}),
|
||||||
|
Forms\Components\TextInput::make('location')
|
||||||
|
->label('Location'),
|
||||||
|
Forms\Components\TextInput::make('bin')
|
||||||
|
->label('Bin'),
|
||||||
|
Forms\Components\TextInput::make('serial_number')
|
||||||
|
->label('Serial Number'),
|
||||||
|
Forms\Components\TextInput::make('batch')
|
||||||
|
->label('Batch'),
|
||||||
|
Forms\Components\TextInput::make('quantity')
|
||||||
|
->label('Quantity'),
|
||||||
|
Forms\Components\TextInput::make('doc_no')
|
||||||
|
->label('Doc No'),
|
||||||
|
Forms\Components\Select::make('type')
|
||||||
|
->label('Type')
|
||||||
|
->options([
|
||||||
|
'0' => 'FG',
|
||||||
|
'1' => 'SFG',
|
||||||
|
]),
|
||||||
|
Forms\Components\TextInput::make('motor_scanned_status')
|
||||||
|
->label('Motor Scanned Status'),
|
||||||
|
Forms\Components\TextInput::make('pump_scanned_status')
|
||||||
|
->label('Pump Scanned Status'),
|
||||||
|
Forms\Components\TextInput::make('capacitor_scanned_status')
|
||||||
|
->label('Capacitor Scanned Status'),
|
||||||
|
Forms\Components\TextInput::make('scanned_status_set')
|
||||||
|
->label('Scanned Status Set'),
|
||||||
|
Forms\Components\TextInput::make('panel_box_item_code')
|
||||||
|
->label('Panel Box Item Code'),
|
||||||
|
Forms\Components\TextInput::make('panel_box_supplier')
|
||||||
|
->label('Panel Box Supplier'),
|
||||||
|
Forms\Components\TextInput::make('panel_box_sno')
|
||||||
|
->label('Panel Box Sno'),
|
||||||
|
Forms\Components\TextInput::make('scanned_status')
|
||||||
|
->label('Scanned Status'),
|
||||||
|
Forms\Components\TextInput::make('scanned_count')
|
||||||
|
->label('Scanned Count'),
|
||||||
|
Forms\Components\Hidden::make('created_by')
|
||||||
|
->label('Created By')
|
||||||
|
->default(Filament::auth()->user()?->name),
|
||||||
|
Forms\Components\Hidden::make('updated_by')
|
||||||
|
->label('Updated By')
|
||||||
|
->default(Filament::auth()->user()?->name),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function table(Table $table): Table
|
||||||
|
{
|
||||||
|
return $table
|
||||||
|
->columns([
|
||||||
|
Tables\Columns\TextColumn::make('No.')
|
||||||
|
->label('No.')
|
||||||
|
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||||
|
$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')
|
||||||
|
->label('Plant')
|
||||||
|
->alignCenter()
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('stickerMaster.item.code')
|
||||||
|
->label('Item Code')
|
||||||
|
->alignCenter()
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('type')
|
||||||
|
->label('Type')
|
||||||
|
->alignCenter()
|
||||||
|
->searchable()
|
||||||
|
->formatStateUsing(fn ($state) => match ($state) {
|
||||||
|
'0' => 'FG',
|
||||||
|
'1' => 'SFG',
|
||||||
|
default => '-',
|
||||||
|
})
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('location')
|
||||||
|
->label('Location')
|
||||||
|
->alignCenter()
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('bin')
|
||||||
|
->label('Bin')
|
||||||
|
->alignCenter()
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('serial_number')
|
||||||
|
->label('Serial Number')
|
||||||
|
->alignCenter()
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('batch')
|
||||||
|
->label('Batch')
|
||||||
|
->alignCenter()
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('quantity')
|
||||||
|
->label('Quantity')
|
||||||
|
->alignCenter()
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('doc_no')
|
||||||
|
->label('Document Number')
|
||||||
|
->alignCenter()
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('motor_scanned_status')
|
||||||
|
->label('Motor Scanned Status')
|
||||||
|
->alignCenter()
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('pump_scanned_status')
|
||||||
|
->label('Pump Scanned Status')
|
||||||
|
->alignCenter()
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('capacitor_scanned_status')
|
||||||
|
->label('Capacitor Scanned Status')
|
||||||
|
->alignCenter()
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('scanned_status_set')
|
||||||
|
->label('Scanned Status Set')
|
||||||
|
->alignCenter()
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('panel_box_item_code')
|
||||||
|
->label('Panel Box Item Code')
|
||||||
|
->alignCenter()
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('panel_box_supplier')
|
||||||
|
->label('Panel Box Supplier')
|
||||||
|
->alignCenter()
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('panel_box_sno')
|
||||||
|
->label('Panel Box Serial Number')
|
||||||
|
->alignCenter()
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('scanned_status')
|
||||||
|
->label('Scanned Status')
|
||||||
|
->alignCenter()
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('scanned_quantity')
|
||||||
|
->label('Scanned Quantity')
|
||||||
|
->alignCenter()
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('created_at')
|
||||||
|
->label('Created At')
|
||||||
|
->alignCenter()
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
Tables\Columns\TextColumn::make('updated_at')
|
||||||
|
->label('Updated At')
|
||||||
|
->alignCenter()
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
Tables\Columns\TextColumn::make('deleted_at')
|
||||||
|
->label('Deleted At')
|
||||||
|
->alignCenter()
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
])
|
||||||
|
->filters([
|
||||||
|
Tables\Filters\TrashedFilter::make(),
|
||||||
|
])
|
||||||
|
->actions([
|
||||||
|
Tables\Actions\ViewAction::make(),
|
||||||
|
Tables\Actions\EditAction::make(),
|
||||||
|
])
|
||||||
|
->bulkActions([
|
||||||
|
Tables\Actions\BulkActionGroup::make([
|
||||||
|
Tables\Actions\DeleteBulkAction::make(),
|
||||||
|
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||||
|
Tables\Actions\RestoreBulkAction::make(),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getRelations(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'index' => Pages\ListNotInStocks::route('/'),
|
||||||
|
'create' => Pages\CreateNotInStock::route('/create'),
|
||||||
|
'view' => Pages\ViewNotInStock::route('/{record}'),
|
||||||
|
'edit' => Pages\EditNotInStock::route('/{record}/edit'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getEloquentQuery(): Builder
|
||||||
|
{
|
||||||
|
return parent::getEloquentQuery()
|
||||||
|
->withoutGlobalScopes([
|
||||||
|
SoftDeletingScope::class,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\NotInStockResource\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\NotInStockResource;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\CreateRecord;
|
||||||
|
|
||||||
|
class CreateNotInStock extends CreateRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = NotInStockResource::class;
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\NotInStockResource\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\NotInStockResource;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\EditRecord;
|
||||||
|
|
||||||
|
class EditNotInStock extends EditRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = NotInStockResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Actions\ViewAction::make(),
|
||||||
|
Actions\DeleteAction::make(),
|
||||||
|
Actions\ForceDeleteAction::make(),
|
||||||
|
Actions\RestoreAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\NotInStockResource\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\NotInStockResource;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\ListRecords;
|
||||||
|
|
||||||
|
class ListNotInStocks extends ListRecords
|
||||||
|
{
|
||||||
|
protected static string $resource = NotInStockResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Actions\CreateAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\NotInStockResource\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\NotInStockResource;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\ViewRecord;
|
||||||
|
|
||||||
|
class ViewNotInStock extends ViewRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = NotInStockResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Actions\EditAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user