Warenwirtschaft: OPT-2 Settings-CRUD-Basisklasse
- Abstrakte SettingCrudController-Basis für die kleinen Stammdaten-CRUDs - TaxRate/DeliveryTime/DisposalReason/MaterialQuality/Location/SupplierCategory/PackagingMaterial auf ~25-Zeilen-Konfiguration reduziert - Identische Update*Request-Klassen entfernt (Update nutzt Store-Request, via updateRequestClass() überschreibbar) - Bilanz -441/+73 Zeilen; Grundlage für die Lagerort-CRUDs in AP-21 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
65f949dd7a
commit
8c90d95c69
16 changed files with 216 additions and 445 deletions
|
|
@ -2,53 +2,28 @@
|
|||
|
||||
namespace App\Http\Controllers\Admin\Inventory;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Inventory\StoreDeliveryTimeRequest;
|
||||
use App\Http\Requests\Inventory\UpdateDeliveryTimeRequest;
|
||||
use App\Models\DeliveryTime;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
|
||||
class DeliveryTimeController extends Controller
|
||||
class DeliveryTimeController extends SettingCrudController
|
||||
{
|
||||
public function create(): View
|
||||
protected function modelClass(): string
|
||||
{
|
||||
return view('admin.inventory.delivery-times.form', [
|
||||
'model' => new DeliveryTime(['active' => true, 'pos' => 0]),
|
||||
]);
|
||||
return DeliveryTime::class;
|
||||
}
|
||||
|
||||
public function store(StoreDeliveryTimeRequest $request): RedirectResponse
|
||||
protected function viewPrefix(): string
|
||||
{
|
||||
DeliveryTime::create($request->validated());
|
||||
|
||||
\Session::flash('alert-save', '1');
|
||||
|
||||
return redirect()->route('admin.inventory.general');
|
||||
return 'admin.inventory.delivery-times';
|
||||
}
|
||||
|
||||
public function edit(DeliveryTime $deliveryTime): View
|
||||
protected function redirectRoute(): string
|
||||
{
|
||||
return view('admin.inventory.delivery-times.form', [
|
||||
'model' => $deliveryTime,
|
||||
]);
|
||||
return 'admin.inventory.general';
|
||||
}
|
||||
|
||||
public function update(UpdateDeliveryTimeRequest $request, DeliveryTime $deliveryTime): RedirectResponse
|
||||
protected function storeRequestClass(): string
|
||||
{
|
||||
$deliveryTime->update($request->validated());
|
||||
|
||||
\Session::flash('alert-save', '1');
|
||||
|
||||
return redirect()->route('admin.inventory.general');
|
||||
}
|
||||
|
||||
public function destroy(DeliveryTime $deliveryTime): RedirectResponse
|
||||
{
|
||||
$deliveryTime->delete();
|
||||
|
||||
\Session::flash('alert-success', __('Eintrag gelöscht'));
|
||||
|
||||
return redirect()->route('admin.inventory.general');
|
||||
return StoreDeliveryTimeRequest::class;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,53 +2,28 @@
|
|||
|
||||
namespace App\Http\Controllers\Admin\Inventory;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Inventory\StoreDisposalReasonRequest;
|
||||
use App\Http\Requests\Inventory\UpdateDisposalReasonRequest;
|
||||
use App\Models\DisposalReason;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
|
||||
class DisposalReasonController extends Controller
|
||||
class DisposalReasonController extends SettingCrudController
|
||||
{
|
||||
public function create(): View
|
||||
protected function modelClass(): string
|
||||
{
|
||||
return view('admin.inventory.disposal-reasons.form', [
|
||||
'model' => new DisposalReason(['active' => true, 'pos' => 0]),
|
||||
]);
|
||||
return DisposalReason::class;
|
||||
}
|
||||
|
||||
public function store(StoreDisposalReasonRequest $request): RedirectResponse
|
||||
protected function viewPrefix(): string
|
||||
{
|
||||
DisposalReason::create($request->validated());
|
||||
|
||||
\Session::flash('alert-save', '1');
|
||||
|
||||
return redirect()->route('admin.inventory.general');
|
||||
return 'admin.inventory.disposal-reasons';
|
||||
}
|
||||
|
||||
public function edit(DisposalReason $disposalReason): View
|
||||
protected function redirectRoute(): string
|
||||
{
|
||||
return view('admin.inventory.disposal-reasons.form', [
|
||||
'model' => $disposalReason,
|
||||
]);
|
||||
return 'admin.inventory.general';
|
||||
}
|
||||
|
||||
public function update(UpdateDisposalReasonRequest $request, DisposalReason $disposalReason): RedirectResponse
|
||||
protected function storeRequestClass(): string
|
||||
{
|
||||
$disposalReason->update($request->validated());
|
||||
|
||||
\Session::flash('alert-save', '1');
|
||||
|
||||
return redirect()->route('admin.inventory.general');
|
||||
}
|
||||
|
||||
public function destroy(DisposalReason $disposalReason): RedirectResponse
|
||||
{
|
||||
$disposalReason->delete();
|
||||
|
||||
\Session::flash('alert-success', __('Eintrag gelöscht'));
|
||||
|
||||
return redirect()->route('admin.inventory.general');
|
||||
return StoreDisposalReasonRequest::class;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,58 +2,38 @@
|
|||
|
||||
namespace App\Http\Controllers\Admin\Inventory;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Inventory\StoreLocationRequest;
|
||||
use App\Http\Requests\Inventory\UpdateLocationRequest;
|
||||
use App\Models\Location;
|
||||
|
||||
class LocationController extends Controller
|
||||
class LocationController extends SettingCrudController
|
||||
{
|
||||
public function index()
|
||||
protected function modelClass(): string
|
||||
{
|
||||
return view('admin.inventory.locations.index', [
|
||||
'values' => Location::query()->orderBy('name')->get(),
|
||||
]);
|
||||
return Location::class;
|
||||
}
|
||||
|
||||
public function create()
|
||||
protected function viewPrefix(): string
|
||||
{
|
||||
return view('admin.inventory.locations.form', [
|
||||
'model' => new Location(['active' => true]),
|
||||
]);
|
||||
return 'admin.inventory.locations';
|
||||
}
|
||||
|
||||
public function store(StoreLocationRequest $request)
|
||||
protected function redirectRoute(): string
|
||||
{
|
||||
Location::create($request->validated());
|
||||
|
||||
\Session::flash('alert-save', '1');
|
||||
|
||||
return redirect()->route('admin.inventory.locations.index');
|
||||
return 'admin.inventory.locations.index';
|
||||
}
|
||||
|
||||
public function edit(Location $location)
|
||||
protected function storeRequestClass(): string
|
||||
{
|
||||
return view('admin.inventory.locations.form', [
|
||||
'model' => $location,
|
||||
]);
|
||||
return StoreLocationRequest::class;
|
||||
}
|
||||
|
||||
public function update(UpdateLocationRequest $request, Location $location)
|
||||
protected function newModelAttributes(): array
|
||||
{
|
||||
$location->update($request->validated());
|
||||
|
||||
\Session::flash('alert-save', '1');
|
||||
|
||||
return redirect()->route('admin.inventory.locations.index');
|
||||
return ['active' => true];
|
||||
}
|
||||
|
||||
public function destroy(Location $location)
|
||||
protected function indexOrder(): array
|
||||
{
|
||||
$location->delete();
|
||||
|
||||
\Session::flash('alert-success', __('Eintrag gelöscht'));
|
||||
|
||||
return redirect()->route('admin.inventory.locations.index');
|
||||
return ['name'];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,58 +2,33 @@
|
|||
|
||||
namespace App\Http\Controllers\Admin\Inventory;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Inventory\StoreMaterialQualityRequest;
|
||||
use App\Http\Requests\Inventory\UpdateMaterialQualityRequest;
|
||||
use App\Models\MaterialQuality;
|
||||
|
||||
class MaterialQualityController extends Controller
|
||||
class MaterialQualityController extends SettingCrudController
|
||||
{
|
||||
public function index()
|
||||
protected function modelClass(): string
|
||||
{
|
||||
return view('admin.inventory.material-qualities.index', [
|
||||
'values' => MaterialQuality::query()->orderBy('pos')->orderBy('name')->get(),
|
||||
]);
|
||||
return MaterialQuality::class;
|
||||
}
|
||||
|
||||
public function create()
|
||||
protected function viewPrefix(): string
|
||||
{
|
||||
return view('admin.inventory.material-qualities.form', [
|
||||
'model' => new MaterialQuality(['pos' => 0]),
|
||||
]);
|
||||
return 'admin.inventory.material-qualities';
|
||||
}
|
||||
|
||||
public function store(StoreMaterialQualityRequest $request)
|
||||
protected function redirectRoute(): string
|
||||
{
|
||||
MaterialQuality::create($request->validated());
|
||||
|
||||
\Session::flash('alert-save', '1');
|
||||
|
||||
return redirect()->route('admin.inventory.material-qualities.index');
|
||||
return 'admin.inventory.material-qualities.index';
|
||||
}
|
||||
|
||||
public function edit(MaterialQuality $materialQuality)
|
||||
protected function storeRequestClass(): string
|
||||
{
|
||||
return view('admin.inventory.material-qualities.form', [
|
||||
'model' => $materialQuality,
|
||||
]);
|
||||
return StoreMaterialQualityRequest::class;
|
||||
}
|
||||
|
||||
public function update(UpdateMaterialQualityRequest $request, MaterialQuality $materialQuality)
|
||||
protected function newModelAttributes(): array
|
||||
{
|
||||
$materialQuality->update($request->validated());
|
||||
|
||||
\Session::flash('alert-save', '1');
|
||||
|
||||
return redirect()->route('admin.inventory.material-qualities.index');
|
||||
}
|
||||
|
||||
public function destroy(MaterialQuality $materialQuality)
|
||||
{
|
||||
$materialQuality->delete();
|
||||
|
||||
\Session::flash('alert-success', __('Eintrag gelöscht'));
|
||||
|
||||
return redirect()->route('admin.inventory.material-qualities.index');
|
||||
return ['pos' => 0];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,58 +2,33 @@
|
|||
|
||||
namespace App\Http\Controllers\Admin\Inventory;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Inventory\StorePackagingMaterialRequest;
|
||||
use App\Http\Requests\Inventory\UpdatePackagingMaterialRequest;
|
||||
use App\Models\PackagingMaterial;
|
||||
|
||||
class PackagingMaterialController extends Controller
|
||||
class PackagingMaterialController extends SettingCrudController
|
||||
{
|
||||
public function index()
|
||||
protected function modelClass(): string
|
||||
{
|
||||
return view('admin.inventory.packaging-materials.index', [
|
||||
'values' => PackagingMaterial::query()->orderBy('pos')->orderBy('name')->get(),
|
||||
]);
|
||||
return PackagingMaterial::class;
|
||||
}
|
||||
|
||||
public function create()
|
||||
protected function viewPrefix(): string
|
||||
{
|
||||
return view('admin.inventory.packaging-materials.form', [
|
||||
'model' => new PackagingMaterial(['pos' => 0]),
|
||||
]);
|
||||
return 'admin.inventory.packaging-materials';
|
||||
}
|
||||
|
||||
public function store(StorePackagingMaterialRequest $request)
|
||||
protected function redirectRoute(): string
|
||||
{
|
||||
PackagingMaterial::create($request->validated());
|
||||
|
||||
\Session::flash('alert-save', '1');
|
||||
|
||||
return redirect()->route('admin.inventory.packaging-materials.index');
|
||||
return 'admin.inventory.packaging-materials.index';
|
||||
}
|
||||
|
||||
public function edit(PackagingMaterial $packagingMaterial)
|
||||
protected function storeRequestClass(): string
|
||||
{
|
||||
return view('admin.inventory.packaging-materials.form', [
|
||||
'model' => $packagingMaterial,
|
||||
]);
|
||||
return StorePackagingMaterialRequest::class;
|
||||
}
|
||||
|
||||
public function update(UpdatePackagingMaterialRequest $request, PackagingMaterial $packagingMaterial)
|
||||
protected function newModelAttributes(): array
|
||||
{
|
||||
$packagingMaterial->update($request->validated());
|
||||
|
||||
\Session::flash('alert-save', '1');
|
||||
|
||||
return redirect()->route('admin.inventory.packaging-materials.index');
|
||||
}
|
||||
|
||||
public function destroy(PackagingMaterial $packagingMaterial)
|
||||
{
|
||||
$packagingMaterial->delete();
|
||||
|
||||
\Session::flash('alert-success', __('Eintrag gelöscht'));
|
||||
|
||||
return redirect()->route('admin.inventory.packaging-materials.index');
|
||||
return ['pos' => 0];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
139
app/Http/Controllers/Admin/Inventory/SettingCrudController.php
Normal file
139
app/Http/Controllers/Admin/Inventory/SettingCrudController.php
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Inventory;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
|
||||
/**
|
||||
* Gemeinsame Basis der kleinen Stammdaten-CRUDs (Warenwirtschaft → Einstellungen).
|
||||
* Kind-Controller definieren nur Model, View-Prefix, FormRequest und Redirect-Ziel.
|
||||
*/
|
||||
abstract class SettingCrudController extends Controller
|
||||
{
|
||||
/** @return class-string<Model> */
|
||||
abstract protected function modelClass(): string;
|
||||
|
||||
/** View-Prefix, z. B. 'admin.inventory.tax-rates' (erwartet .index/.form darunter). */
|
||||
abstract protected function viewPrefix(): string;
|
||||
|
||||
/** Ziel-Route nach store/update/destroy. */
|
||||
abstract protected function redirectRoute(): string;
|
||||
|
||||
/** @return class-string<FormRequest> */
|
||||
abstract protected function storeRequestClass(): string;
|
||||
|
||||
/** @return class-string<FormRequest> Default: identisch zum Store-Request. */
|
||||
protected function updateRequestClass(): string
|
||||
{
|
||||
return $this->storeRequestClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* Vorbelegung des leeren Models im Neu-Formular.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
protected function newModelAttributes(): array
|
||||
{
|
||||
return ['active' => true, 'pos' => 0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sortierung der Index-Liste (nur für Resources mit index-Route relevant).
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
protected function indexOrder(): array
|
||||
{
|
||||
return ['pos', 'name'];
|
||||
}
|
||||
|
||||
public function index(): View
|
||||
{
|
||||
$query = $this->modelClass()::query();
|
||||
foreach ($this->indexOrder() as $column) {
|
||||
$query->orderBy($column);
|
||||
}
|
||||
|
||||
return view($this->viewPrefix().'.index', [
|
||||
'values' => $query->get(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function create(): View
|
||||
{
|
||||
$class = $this->modelClass();
|
||||
|
||||
return view($this->viewPrefix().'.form', [
|
||||
'model' => new $class($this->newModelAttributes()),
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(): RedirectResponse
|
||||
{
|
||||
$this->modelClass()::create($this->validated($this->storeRequestClass()));
|
||||
|
||||
\Session::flash('alert-save', '1');
|
||||
|
||||
return redirect()->route($this->redirectRoute());
|
||||
}
|
||||
|
||||
public function edit(): View
|
||||
{
|
||||
return view($this->viewPrefix().'.form', [
|
||||
'model' => $this->routeModel(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(): RedirectResponse
|
||||
{
|
||||
$this->routeModel()->update($this->validated($this->updateRequestClass()));
|
||||
|
||||
\Session::flash('alert-save', '1');
|
||||
|
||||
return redirect()->route($this->redirectRoute());
|
||||
}
|
||||
|
||||
public function destroy(): RedirectResponse
|
||||
{
|
||||
$this->routeModel()->delete();
|
||||
|
||||
\Session::flash('alert-success', __('Eintrag gelöscht'));
|
||||
|
||||
return redirect()->route($this->redirectRoute());
|
||||
}
|
||||
|
||||
/**
|
||||
* Validiert den aktuellen Request über den angegebenen FormRequest
|
||||
* (Container-Auflösung triggert die Validierung wie bei Method-Injection).
|
||||
*
|
||||
* @param class-string<FormRequest> $requestClass
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
protected function validated(string $requestClass): array
|
||||
{
|
||||
/** @var FormRequest $request */
|
||||
$request = app($requestClass);
|
||||
|
||||
return $request->validated();
|
||||
}
|
||||
|
||||
/**
|
||||
* Löst das Model aus dem Resource-Routen-Parameter auf (ohne Typehint
|
||||
* greift kein implizites Binding, der Parameter ist die rohe ID).
|
||||
*/
|
||||
protected function routeModel(): Model
|
||||
{
|
||||
$value = array_values(request()->route()->parameters())[0] ?? null;
|
||||
|
||||
if ($value instanceof Model) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
return $this->modelClass()::query()->findOrFail($value);
|
||||
}
|
||||
}
|
||||
|
|
@ -2,58 +2,33 @@
|
|||
|
||||
namespace App\Http\Controllers\Admin\Inventory;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Inventory\StoreSupplierCategoryRequest;
|
||||
use App\Http\Requests\Inventory\UpdateSupplierCategoryRequest;
|
||||
use App\Models\SupplierCategory;
|
||||
|
||||
class SupplierCategoryController extends Controller
|
||||
class SupplierCategoryController extends SettingCrudController
|
||||
{
|
||||
public function index()
|
||||
protected function modelClass(): string
|
||||
{
|
||||
return view('admin.inventory.supplier-categories.index', [
|
||||
'values' => SupplierCategory::query()->orderBy('pos')->orderBy('name')->get(),
|
||||
]);
|
||||
return SupplierCategory::class;
|
||||
}
|
||||
|
||||
public function create()
|
||||
protected function viewPrefix(): string
|
||||
{
|
||||
return view('admin.inventory.supplier-categories.form', [
|
||||
'model' => new SupplierCategory(['pos' => 0]),
|
||||
]);
|
||||
return 'admin.inventory.supplier-categories';
|
||||
}
|
||||
|
||||
public function store(StoreSupplierCategoryRequest $request)
|
||||
protected function redirectRoute(): string
|
||||
{
|
||||
SupplierCategory::create($request->validated());
|
||||
|
||||
\Session::flash('alert-save', '1');
|
||||
|
||||
return redirect()->route('admin.inventory.supplier-categories.index');
|
||||
return 'admin.inventory.supplier-categories.index';
|
||||
}
|
||||
|
||||
public function edit(SupplierCategory $supplierCategory)
|
||||
protected function storeRequestClass(): string
|
||||
{
|
||||
return view('admin.inventory.supplier-categories.form', [
|
||||
'model' => $supplierCategory,
|
||||
]);
|
||||
return StoreSupplierCategoryRequest::class;
|
||||
}
|
||||
|
||||
public function update(UpdateSupplierCategoryRequest $request, SupplierCategory $supplierCategory)
|
||||
protected function newModelAttributes(): array
|
||||
{
|
||||
$supplierCategory->update($request->validated());
|
||||
|
||||
\Session::flash('alert-save', '1');
|
||||
|
||||
return redirect()->route('admin.inventory.supplier-categories.index');
|
||||
}
|
||||
|
||||
public function destroy(SupplierCategory $supplierCategory)
|
||||
{
|
||||
$supplierCategory->delete();
|
||||
|
||||
\Session::flash('alert-success', __('Eintrag gelöscht'));
|
||||
|
||||
return redirect()->route('admin.inventory.supplier-categories.index');
|
||||
return ['pos' => 0];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,53 +2,28 @@
|
|||
|
||||
namespace App\Http\Controllers\Admin\Inventory;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Inventory\StoreTaxRateRequest;
|
||||
use App\Http\Requests\Inventory\UpdateTaxRateRequest;
|
||||
use App\Models\TaxRate;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
|
||||
class TaxRateController extends Controller
|
||||
class TaxRateController extends SettingCrudController
|
||||
{
|
||||
public function create(): View
|
||||
protected function modelClass(): string
|
||||
{
|
||||
return view('admin.inventory.tax-rates.form', [
|
||||
'model' => new TaxRate(['active' => true, 'pos' => 0]),
|
||||
]);
|
||||
return TaxRate::class;
|
||||
}
|
||||
|
||||
public function store(StoreTaxRateRequest $request): RedirectResponse
|
||||
protected function viewPrefix(): string
|
||||
{
|
||||
TaxRate::create($request->validated());
|
||||
|
||||
\Session::flash('alert-save', '1');
|
||||
|
||||
return redirect()->route('admin.inventory.general');
|
||||
return 'admin.inventory.tax-rates';
|
||||
}
|
||||
|
||||
public function edit(TaxRate $taxRate): View
|
||||
protected function redirectRoute(): string
|
||||
{
|
||||
return view('admin.inventory.tax-rates.form', [
|
||||
'model' => $taxRate,
|
||||
]);
|
||||
return 'admin.inventory.general';
|
||||
}
|
||||
|
||||
public function update(UpdateTaxRateRequest $request, TaxRate $taxRate): RedirectResponse
|
||||
protected function storeRequestClass(): string
|
||||
{
|
||||
$taxRate->update($request->validated());
|
||||
|
||||
\Session::flash('alert-save', '1');
|
||||
|
||||
return redirect()->route('admin.inventory.general');
|
||||
}
|
||||
|
||||
public function destroy(TaxRate $taxRate): RedirectResponse
|
||||
{
|
||||
$taxRate->delete();
|
||||
|
||||
\Session::flash('alert-success', __('Eintrag gelöscht'));
|
||||
|
||||
return redirect()->route('admin.inventory.general');
|
||||
return StoreTaxRateRequest::class;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,35 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Inventory;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateDeliveryTimeRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array<int, string>>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'label' => ['required', 'string', 'max:255'],
|
||||
'days' => ['nullable', 'integer', 'min:0', 'max:65535'],
|
||||
'active' => ['sometimes', 'boolean'],
|
||||
'pos' => ['nullable', 'integer', 'min:0', 'max:255'],
|
||||
];
|
||||
}
|
||||
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'active' => $this->boolean('active'),
|
||||
'days' => $this->input('days', '') === '' ? null : $this->input('days'),
|
||||
'pos' => $this->input('pos', '') === '' ? 0 : $this->input('pos'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Inventory;
|
||||
|
||||
class UpdateDisposalReasonRequest extends StoreDisposalReasonRequest {}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Inventory;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateLocationRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array<int, string>>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'active' => ['sometimes', 'boolean'],
|
||||
];
|
||||
}
|
||||
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'active' => $this->boolean('active'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Inventory;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateMaterialQualityRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array<int, string>>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'pos' => ['nullable', 'integer', 'min:0', 'max:255'],
|
||||
];
|
||||
}
|
||||
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
if ($this->has('pos') && $this->input('pos') === '') {
|
||||
$this->merge(['pos' => 0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Inventory;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdatePackagingMaterialRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array<int, string>>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'pos' => ['nullable', 'integer', 'min:0', 'max:255'],
|
||||
];
|
||||
}
|
||||
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
if ($this->has('pos') && $this->input('pos') === '') {
|
||||
$this->merge(['pos' => 0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Inventory;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateSupplierCategoryRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array<int, string>>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'pos' => ['nullable', 'integer', 'min:0', 'max:255'],
|
||||
];
|
||||
}
|
||||
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
if ($this->has('pos') && $this->input('pos') === '') {
|
||||
$this->merge(['pos' => 0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Inventory;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateTaxRateRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array<int, string>>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'percent' => ['required', 'numeric', 'min:0', 'max:100'],
|
||||
'active' => ['sometimes', 'boolean'],
|
||||
'pos' => ['nullable', 'integer', 'min:0', 'max:255'],
|
||||
];
|
||||
}
|
||||
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'active' => $this->boolean('active'),
|
||||
'pos' => $this->input('pos', '') === '' ? 0 : $this->input('pos'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue