Initial commit
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* Walidacja dodania/edycji typu kabla (site206A/E). Pliki opcjonalne:
|
||||
* dokumentacja katalogowa (PDF/Office) oraz zdjęcie. Limit 8 MB (mediumblob 16 MB).
|
||||
*/
|
||||
class StoreCableRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'manufacturer_id' => ['required', 'integer', 'exists:seg_manufacturers,MCF_ID'],
|
||||
'description' => ['nullable', 'string', 'max:255'],
|
||||
'catalogue_file' => ['nullable', 'file', 'mimes:pdf,doc,docx,xls,xlsx,ppt,pptx', 'max:8192'],
|
||||
'image_file' => ['nullable', 'image', 'mimes:jpg,jpeg,png,gif,bmp', 'max:8192'],
|
||||
];
|
||||
}
|
||||
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'typ kabla',
|
||||
'manufacturer_id' => 'producent',
|
||||
'description' => 'opis',
|
||||
'catalogue_file' => 'dokumentacja katalogowa',
|
||||
'image_file' => 'zdjęcie',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class StoreEngineRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
foreach (['power', 'voltage', 'current', 'eta', 'cos_fi', 'rpm', 'length', 'weight', 'diameter'] as $f) {
|
||||
$this->merge([$f => $this->dec($this->$f)]);
|
||||
}
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
// Unikalność: nazwa + napięcie (jak legacy).
|
||||
'name' => ['required', 'string', 'max:128', Rule::unique('seg_engines', 'ENG_NAME')->where(fn ($q) => $q->where('ENG_VOLTAGE', $this->voltage))],
|
||||
'manufacturer_id' => ['required', 'integer', 'exists:seg_manufacturers,MCF_ID'],
|
||||
'power' => ['required', 'numeric'],
|
||||
'voltage' => ['required', 'numeric'],
|
||||
'current' => ['nullable', 'numeric'],
|
||||
'eta' => ['nullable', 'numeric'],
|
||||
'cos_fi' => ['nullable', 'numeric'],
|
||||
'rpm' => ['nullable', 'numeric'],
|
||||
'length' => ['nullable', 'numeric'],
|
||||
'weight' => ['nullable', 'numeric'],
|
||||
'diameter' => ['nullable', 'numeric'],
|
||||
'wires' => ['nullable', 'string', 'max:32'],
|
||||
];
|
||||
}
|
||||
|
||||
private function dec(mixed $v): ?string
|
||||
{
|
||||
return $v === null || $v === '' ? null : str_replace(',', '.', (string) $v);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* Walidacja dodania/edycji urządzenia opomiarowania (site208A/E). Pola jak
|
||||
* w kablach (nazwa, producent, opis, pliki). Kategoria (EQU_PARAM_02=SPM_FULL)
|
||||
* ustawiana automatycznie w serwisie/kontrolerze - jak legacy normalny dodawania.
|
||||
*/
|
||||
class StoreMeteringRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'manufacturer_id' => ['required', 'integer', 'exists:seg_manufacturers,MCF_ID'],
|
||||
'description' => ['nullable', 'string', 'max:255'],
|
||||
'catalogue_file' => ['nullable', 'file', 'mimes:pdf,doc,docx,xls,xlsx,ppt,pptx', 'max:8192'],
|
||||
'image_file' => ['nullable', 'image', 'mimes:jpg,jpeg,png,gif,bmp', 'max:8192'],
|
||||
];
|
||||
}
|
||||
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'nazwa',
|
||||
'manufacturer_id' => 'producent',
|
||||
'description' => 'opis',
|
||||
'catalogue_file' => 'dokumentacja katalogowa',
|
||||
'image_file' => 'zdjęcie',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* Walidacja dodania/edycji orurowania i armatury (site207A/E). Średnica
|
||||
* wymagana (legacy float_req), długość/ciśnienie opcjonalne. Pliki jak w kablach.
|
||||
*/
|
||||
class StorePipingRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'manufacturer_id' => ['required', 'integer', 'exists:seg_manufacturers,MCF_ID'],
|
||||
'diameter' => ['required', 'string', 'max:128'],
|
||||
'length' => ['nullable', 'string', 'max:128'],
|
||||
'description' => ['nullable', 'string', 'max:255'],
|
||||
'catalogue_file' => ['nullable', 'file', 'mimes:pdf,doc,docx,xls,xlsx,ppt,pptx', 'max:8192'],
|
||||
'image_file' => ['nullable', 'image', 'mimes:jpg,jpeg,png,gif,bmp', 'max:8192'],
|
||||
];
|
||||
}
|
||||
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'nazwa',
|
||||
'manufacturer_id' => 'producent',
|
||||
'diameter' => 'średnica',
|
||||
'length' => 'długość / ciśnienie',
|
||||
'description' => 'opis',
|
||||
'catalogue_file' => 'dokumentacja katalogowa',
|
||||
'image_file' => 'zdjęcie',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StorePumpRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'q_n' => $this->dec($this->q_n),
|
||||
'length' => $this->dec($this->length),
|
||||
'diameter' => $this->dec($this->diameter),
|
||||
'weight' => $this->dec($this->weight),
|
||||
'h' => collect($this->h ?? [])->map(fn ($v) => $this->dec($v))->all(),
|
||||
'eta' => collect($this->eta ?? [])->map(fn ($v) => $this->dec($v))->all(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'string', 'max:128', 'unique:seg_pumps,PUP_NAME'],
|
||||
'manufacturer_id' => ['required', 'integer', 'exists:seg_manufacturers,MCF_ID'],
|
||||
'q_n' => ['required', 'numeric', 'gt:0'],
|
||||
// 8 punktów krzywych - H wymagane (>0), η wymagane (0 dozwolone przy Q=0).
|
||||
'h' => ['required', 'array', 'size:8'],
|
||||
'h.*' => ['required', 'numeric'],
|
||||
'eta' => ['required', 'array', 'size:8'],
|
||||
'eta.*' => ['required', 'numeric'],
|
||||
'length' => ['nullable', 'numeric'],
|
||||
'diameter' => ['nullable', 'numeric'],
|
||||
'weight' => ['nullable', 'numeric'],
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'h.*.required' => 'Podaj wartość H dla każdego punktu Q.',
|
||||
'eta.*.required' => 'Podaj wartość η dla każdego punktu Q.',
|
||||
];
|
||||
}
|
||||
|
||||
private function dec(mixed $v): ?string
|
||||
{
|
||||
return $v === null || $v === '' ? null : str_replace(',', '.', (string) $v);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* Walidacja edycji typu kabla (site206E). Reguły jak przy dodawaniu - wgranie
|
||||
* nowego pliku zastępuje dotychczasowy tej samej roli; brak pliku = bez zmian.
|
||||
*/
|
||||
class UpdateCableRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'manufacturer_id' => ['required', 'integer', 'exists:seg_manufacturers,MCF_ID'],
|
||||
'description' => ['nullable', 'string', 'max:255'],
|
||||
'catalogue_file' => ['nullable', 'file', 'mimes:pdf,doc,docx,xls,xlsx,ppt,pptx', 'max:8192'],
|
||||
'image_file' => ['nullable', 'image', 'mimes:jpg,jpeg,png,gif,bmp', 'max:8192'],
|
||||
];
|
||||
}
|
||||
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'typ kabla',
|
||||
'manufacturer_id' => 'producent',
|
||||
'description' => 'opis',
|
||||
'catalogue_file' => 'dokumentacja katalogowa',
|
||||
'image_file' => 'zdjęcie',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class UpdateEngineRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
foreach (['power', 'voltage', 'current', 'eta', 'cos_fi', 'rpm', 'length', 'weight', 'diameter'] as $f) {
|
||||
$this->merge([$f => $this->dec($this->$f)]);
|
||||
}
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'string', 'max:128', Rule::unique('seg_engines', 'ENG_NAME')->where(fn ($q) => $q->where('ENG_VOLTAGE', $this->voltage))->ignore($this->route('engine'))],
|
||||
'manufacturer_id' => ['required', 'integer', 'exists:seg_manufacturers,MCF_ID'],
|
||||
'power' => ['required', 'numeric'],
|
||||
'voltage' => ['required', 'numeric'],
|
||||
'current' => ['nullable', 'numeric'],
|
||||
'eta' => ['nullable', 'numeric'],
|
||||
'cos_fi' => ['nullable', 'numeric'],
|
||||
'rpm' => ['nullable', 'numeric'],
|
||||
'length' => ['nullable', 'numeric'],
|
||||
'weight' => ['nullable', 'numeric'],
|
||||
'diameter' => ['nullable', 'numeric'],
|
||||
'wires' => ['nullable', 'string', 'max:32'],
|
||||
];
|
||||
}
|
||||
|
||||
private function dec(mixed $v): ?string
|
||||
{
|
||||
return $v === null || $v === '' ? null : str_replace(',', '.', (string) $v);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* Walidacja edycji urządzenia opomiarowania (site208E). Reguły jak przy
|
||||
* dodawaniu; wgranie nowego pliku zastępuje dotychczasowy tej samej roli.
|
||||
*/
|
||||
class UpdateMeteringRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'manufacturer_id' => ['required', 'integer', 'exists:seg_manufacturers,MCF_ID'],
|
||||
'description' => ['nullable', 'string', 'max:255'],
|
||||
'catalogue_file' => ['nullable', 'file', 'mimes:pdf,doc,docx,xls,xlsx,ppt,pptx', 'max:8192'],
|
||||
'image_file' => ['nullable', 'image', 'mimes:jpg,jpeg,png,gif,bmp', 'max:8192'],
|
||||
];
|
||||
}
|
||||
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'nazwa',
|
||||
'manufacturer_id' => 'producent',
|
||||
'description' => 'opis',
|
||||
'catalogue_file' => 'dokumentacja katalogowa',
|
||||
'image_file' => 'zdjęcie',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* Walidacja edycji orurowania i armatury (site207E). Reguły jak przy dodawaniu;
|
||||
* wgranie nowego pliku zastępuje dotychczasowy tej samej roli.
|
||||
*/
|
||||
class UpdatePipingRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'manufacturer_id' => ['required', 'integer', 'exists:seg_manufacturers,MCF_ID'],
|
||||
'diameter' => ['required', 'string', 'max:128'],
|
||||
'length' => ['nullable', 'string', 'max:128'],
|
||||
'description' => ['nullable', 'string', 'max:255'],
|
||||
'catalogue_file' => ['nullable', 'file', 'mimes:pdf,doc,docx,xls,xlsx,ppt,pptx', 'max:8192'],
|
||||
'image_file' => ['nullable', 'image', 'mimes:jpg,jpeg,png,gif,bmp', 'max:8192'],
|
||||
];
|
||||
}
|
||||
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'nazwa',
|
||||
'manufacturer_id' => 'producent',
|
||||
'diameter' => 'średnica',
|
||||
'length' => 'długość / ciśnienie',
|
||||
'description' => 'opis',
|
||||
'catalogue_file' => 'dokumentacja katalogowa',
|
||||
'image_file' => 'zdjęcie',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class UpdatePumpRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'length' => $this->dec($this->length),
|
||||
'diameter' => $this->dec($this->diameter),
|
||||
'weight' => $this->dec($this->weight),
|
||||
'h' => collect($this->h ?? [])->map(fn ($v) => $this->dec($v))->all(),
|
||||
'eta' => collect($this->eta ?? [])->map(fn ($v) => $this->dec($v))->all(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'string', 'max:128', Rule::unique('seg_pumps', 'PUP_NAME')->ignore($this->route('pump'))],
|
||||
'manufacturer_id' => ['required', 'integer', 'exists:seg_manufacturers,MCF_ID'],
|
||||
'length' => ['nullable', 'numeric'],
|
||||
'diameter' => ['nullable', 'numeric'],
|
||||
'weight' => ['nullable', 'numeric'],
|
||||
'h' => ['nullable', 'array'],
|
||||
'h.*' => ['nullable', 'numeric'],
|
||||
'eta' => ['nullable', 'array'],
|
||||
'eta.*' => ['nullable', 'numeric'],
|
||||
];
|
||||
}
|
||||
|
||||
private function dec(mixed $v): ?string
|
||||
{
|
||||
return $v === null || $v === '' ? null : str_replace(',', '.', (string) $v);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user