156 lines
5.0 KiB
PHP
156 lines
5.0 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources;
|
|
|
|
use App\Filament\Resources\InvoiceValidationResource\Pages;
|
|
use App\Models\InvoiceValidation;
|
|
use Filament\Forms;
|
|
use Filament\Forms\Components\Section;
|
|
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;
|
|
use Filament\Forms\Components\View;
|
|
|
|
|
|
|
|
class InvoiceValidationResource extends Resource
|
|
{
|
|
protected static ?string $model = InvoiceValidation::class;
|
|
|
|
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
|
|
|
protected static ?string $navigationGroup = 'Invoice';
|
|
|
|
public $enter_pressed = false;
|
|
|
|
public static function form(Form $form): Form
|
|
{
|
|
return $form
|
|
->schema([
|
|
Forms\Components\Hidden::make('sticker_master_id')
|
|
//->relationship('stickerMaster', 'id')
|
|
->required(),
|
|
|
|
Section::make('')
|
|
->schema([
|
|
|
|
// FileUpload::make('excel_file')
|
|
// ->label('Choose Excel File')
|
|
// ->disk('local')
|
|
// ->columnSpan(1),
|
|
|
|
Forms\Components\Select::make('plant_id')
|
|
->relationship('plant', 'name')
|
|
->required(),
|
|
|
|
Forms\Components\TextInput::make('invoice_number')
|
|
->required()
|
|
->label('Invoice Number')
|
|
->columnSpan(1)
|
|
->extraAttributes([
|
|
'x-data' => '{ value: "" }',
|
|
'x-model' => 'value',
|
|
'x-on:keydown.enter.prevent' => '$wire.processInvoice(value)',
|
|
]),
|
|
|
|
Forms\Components\TextInput::make('serial_number')
|
|
//->required()
|
|
->reactive()
|
|
->columnSpan(1),
|
|
|
|
Forms\Components\TextInput::make('total_quantity')
|
|
->label('Total Quantity')
|
|
->columnSpan(1),
|
|
Forms\Components\TextInput::make('scanned_quantity')
|
|
->label('Scanned Quantity')
|
|
->columnSpan(1),
|
|
|
|
])
|
|
->columns(5),
|
|
|
|
// View::make('livewire.invoice-data-table')
|
|
// ->label('Invoice Details')
|
|
// ->viewData([
|
|
// 'invoiceData' => fn ($get) => $get('invoice_data') ?? [], // Changed from invoiceData to invoice_data
|
|
// ])
|
|
// ->columnSpan('full'),
|
|
]);
|
|
}
|
|
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
Tables\Columns\TextColumn::make('id')
|
|
->label('ID')
|
|
->numeric()
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('stickerMaster.id')
|
|
->numeric()
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('plant.name')
|
|
->numeric()
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('load_rate')
|
|
->numeric()
|
|
->sortable(),
|
|
Tables\Columns\TextColumn::make('created_at')
|
|
->dateTime()
|
|
->sortable()
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
Tables\Columns\TextColumn::make('updated_at')
|
|
->dateTime()
|
|
->sortable()
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
Tables\Columns\TextColumn::make('deleted_at')
|
|
->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\ListInvoiceValidations::route('/'),
|
|
'create' => Pages\CreateInvoiceValidation::route('/create'),
|
|
'view' => Pages\ViewInvoiceValidation::route('/{record}'),
|
|
'edit' => Pages\EditInvoiceValidation::route('/{record}/edit'),
|
|
];
|
|
}
|
|
|
|
public static function getEloquentQuery(): Builder
|
|
{
|
|
return parent::getEloquentQuery()
|
|
->withoutGlobalScopes([
|
|
SoftDeletingScope::class,
|
|
]);
|
|
}
|
|
}
|