Initial commit for new repo
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 1m4s
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 1m4s
This commit is contained in:
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\QualityValidationResource\Pages;
|
||||
|
||||
use App\Filament\Resources\QualityValidationResource;
|
||||
use App\Models\AlertMailRule;
|
||||
use App\Models\Plant;
|
||||
use Filament\Actions;
|
||||
use Filament\Forms\Components\Component;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class CreateQualityValidation extends CreateRecord
|
||||
{
|
||||
protected static string $resource = QualityValidationResource::class;
|
||||
|
||||
public $plantId;
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
parent::mount();
|
||||
session()->forget([
|
||||
'last_selected_plant_id',
|
||||
'last_selected_line',
|
||||
'last_selected_production',
|
||||
]);
|
||||
}
|
||||
|
||||
protected function beforeCreate(): void
|
||||
{
|
||||
$errors = [];
|
||||
|
||||
if (!empty($this->data['validationError'])) {
|
||||
$errors['validationError'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
if (!empty($this->data['pack_slip_motor_error'])) {
|
||||
$errors['pack_slip_motor_error'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
if (!empty($this->data['pack_slip_pump_error'])) {
|
||||
$errors['pack_slip_pump_error'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
if (!empty($this->data['pack_slip_pumpset_error'])) {
|
||||
$errors['pack_slip_pumpset_error'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
//..name plate
|
||||
|
||||
if (!empty($this->data['name_plate_motor_error'])) {
|
||||
$errors['name_plate_motor_error'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
if (!empty($this->data['name_plate_pump_error'])) {
|
||||
$errors['name_plate_pump_error'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
if (!empty($this->data['name_plate_pumpset_error'])) {
|
||||
$errors['name_plate_pumpset_error'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
//..tube sticker
|
||||
|
||||
if (!empty($this->data['tube_sticker_motor_error'])) {
|
||||
$errors['tube_sticker_motor_error'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
if (!empty($this->data['tube_sticker_pump_error'])) {
|
||||
$errors['tube_sticker_pump_error'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
if (!empty($this->data['tube_sticker_pumpset_error'])) {
|
||||
$errors['tube_sticker_pumpset_error'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
//..warranty
|
||||
if (!empty($this->data['warranty_card_error'])) {
|
||||
$errors['warranty_card_error'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
//..part validations
|
||||
|
||||
if (!empty($this->data['part_validation1_error'])) {
|
||||
$errors['part_validation1_error'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
if (!empty($this->data['part_validation2_error'])) {
|
||||
$errors['part_validation2_error'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
if (!empty($this->data['part_validation3_error'])) {
|
||||
$errors['part_validation3_error'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
if (!empty($this->data['part_validation4_error'])) {
|
||||
$errors['part_validation4_error'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
if (!empty($this->data['part_validation5_error'])) {
|
||||
$errors['part_validation5_error'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
|
||||
if (!empty($errors)) {
|
||||
throw ValidationException::withMessages($errors);
|
||||
}
|
||||
}
|
||||
|
||||
protected function afterCreate(): void
|
||||
{
|
||||
// Get the value from the hidden field 'plant'
|
||||
$plant = $this->form->getState()['plant'] ?? null;
|
||||
$line = $this->form->getState()['line'] ?? null;
|
||||
$production = $this->form->getState()['production'] ?? null;
|
||||
if ($plant) {
|
||||
session(['last_selected_plant_id' => $plant]);
|
||||
}
|
||||
if ($line) {
|
||||
session(['last_selected_line' => $line]);
|
||||
}
|
||||
if ($production) {
|
||||
session(['last_selected_production' => $production]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
//return $this->getResource()::getUrl('create'); // Stay on Create Page after saving
|
||||
|
||||
return $this->getResource()::getUrl('create', [
|
||||
'plant_id' => $this->data['plant_id'] ?? null,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\QualityValidationResource\Pages;
|
||||
|
||||
use App\Filament\Resources\QualityValidationResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditQualityValidation extends EditRecord
|
||||
{
|
||||
protected static string $resource = QualityValidationResource::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\QualityValidationResource\Pages;
|
||||
|
||||
use App\Filament\Resources\QualityValidationResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListQualityValidations extends ListRecords
|
||||
{
|
||||
protected static string $resource = QualityValidationResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\QualityValidationResource\Pages;
|
||||
|
||||
use App\Filament\Resources\QualityValidationResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewQualityValidation extends ViewRecord
|
||||
{
|
||||
protected static string $resource = QualityValidationResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user