Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 12s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 13s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 20s
Laravel Pint / pint (pull_request) Successful in 12m12s
Laravel Larastan / larastan (pull_request) Failing after 15m27s
59 lines
1.8 KiB
PHP
59 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\PanelGrMasterResource\Pages;
|
|
|
|
use App\Filament\Resources\PanelGrMasterResource;
|
|
use App\Models\PanelBoxValidation;
|
|
use App\Models\StickerMaster;
|
|
use Filament\Actions;
|
|
use Filament\Facades\Filament;
|
|
use Filament\Notifications\Notification;
|
|
use Filament\Resources\Pages\EditRecord;
|
|
|
|
class EditPanelGrMaster extends EditRecord
|
|
{
|
|
protected static string $resource = PanelGrMasterResource::class;
|
|
|
|
protected function mutateFormDataBeforeSave(array $data): array
|
|
{
|
|
$record = $this->record;
|
|
|
|
$sticker = StickerMaster::where('plant_id', $record->plant_id)->where('item_id', $record->item_id)->first();
|
|
|
|
if($sticker)
|
|
{
|
|
$scannedQuantity = PanelBoxValidation::where('plant_id', $record->plant_id)
|
|
->where('production_order', $record->document_number)
|
|
->where('inspection_lot_number', $record->inspection_lot_number)
|
|
->where('sticker_master_id', $sticker->id)
|
|
->count();
|
|
}
|
|
|
|
|
|
if ((int) $data['quantity'] < $scannedQuantity) {
|
|
Notification::make()
|
|
->title('Invalid Quantity')
|
|
->body("Already scanned quantity is {$scannedQuantity}.<br>Panel GR Master quantity cannot be less than {$scannedQuantity}.")
|
|
->danger()
|
|
->send();
|
|
$this->halt();
|
|
|
|
}
|
|
|
|
$data['updated_by'] = Filament::auth()->user()?->name;
|
|
$data['updated_at'] = now();
|
|
|
|
return $data;
|
|
}
|
|
|
|
protected function getHeaderActions(): array
|
|
{
|
|
return [
|
|
Actions\ViewAction::make(),
|
|
Actions\DeleteAction::make(),
|
|
Actions\ForceDeleteAction::make(),
|
|
Actions\RestoreAction::make(),
|
|
];
|
|
}
|
|
}
|