added datagrid table
This commit is contained in:
@@ -4,7 +4,10 @@ namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\InvoiceValidationResource\Pages;
|
||||
use App\Models\InvoiceValidation;
|
||||
use App\Models\StickerMaster;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
@@ -13,8 +16,10 @@ use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Forms\Components\View;
|
||||
|
||||
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Tables\Actions\Action;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class InvoiceValidationResource extends Resource
|
||||
{
|
||||
@@ -24,24 +29,18 @@ class InvoiceValidationResource extends Resource
|
||||
|
||||
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(),
|
||||
// Forms\Components\Hidden::make('sticker_master_id')
|
||||
// //->relationship('stickerMaster', 'id')
|
||||
// ->required(),
|
||||
|
||||
Section::make('')
|
||||
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(),
|
||||
@@ -57,7 +56,6 @@ class InvoiceValidationResource extends Resource
|
||||
]),
|
||||
|
||||
Forms\Components\TextInput::make('serial_number')
|
||||
//->required()
|
||||
->reactive()
|
||||
->columnSpan(1),
|
||||
|
||||
@@ -71,16 +69,11 @@ class InvoiceValidationResource extends Resource
|
||||
])
|
||||
->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
|
||||
@@ -98,35 +91,66 @@ class InvoiceValidationResource extends Resource
|
||||
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(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
->headerActions([
|
||||
Tables\Actions\Action::make('Import Serial Number')
|
||||
->label('Import Serial Number')
|
||||
->form([
|
||||
FileUpload::make('invoice_serial_number')
|
||||
->label('Invoice Serial Number')
|
||||
->preserveFilenames() // <- this keeps the original filename
|
||||
->storeFiles(false) // prevent auto-storing, we will store manually
|
||||
->disk('local') //'local' refers to the local storage disk defined in config/filesystems.php, typically pointing to storage/app.
|
||||
->directory('uploads/temp'), //storage/app/uploads/temp
|
||||
])
|
||||
|
||||
->action(function (array $data) {
|
||||
$uploadedFile = $data['invoice_serial_number'];
|
||||
|
||||
// Get original filename
|
||||
$originalName = $uploadedFile->getClientOriginalName(); // e.g. 3RA0018732.xlsx
|
||||
|
||||
// Store manually using storeAs to keep original name
|
||||
$path = $uploadedFile->storeAs('uploads/temp', $originalName, 'local'); // returns relative path
|
||||
|
||||
$fullPath = Storage::disk('local')->path($path);
|
||||
|
||||
// Save full file path to session
|
||||
session(['uploaded_invoice_path' => $fullPath]);
|
||||
|
||||
// session()->flash('just_uploaded_invoice', true); // 👈 add this
|
||||
|
||||
Notification::make()
|
||||
->title('File Uploaded. Continue in Create Page.')
|
||||
->success()
|
||||
->send();
|
||||
}),
|
||||
|
||||
Tables\Actions\Action::make('Import Invoice Material')
|
||||
->label('Import Invoice Material')
|
||||
->form([
|
||||
FileUpload::make('invoice_material')
|
||||
->label('Invoice Material')
|
||||
->required(),
|
||||
])
|
||||
]);
|
||||
|
||||
// ->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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user