move into sonardesk

This commit is contained in:
Mark Gregory
2026-10-12 14:50:13 +01:00
parent 5f0d2ceb72
commit 38b4a7406f
879 changed files with 24021 additions and 1 deletions
@@ -0,0 +1,23 @@
<?php
namespace Modules\Products\Http\Controllers;
use Illuminate\Http\RedirectResponse;
use Illuminate\View\View;
use Modules\Products\Http\Requests\StoreProductRequest;
use Modules\Products\Models\Product;
final class ProductController
{
public function index(): View
{
return view('products::admin.products.index', ['records' => Product::query()->latest()->paginate()]);
}
public function store(StoreProductRequest $request): RedirectResponse
{
Product::query()->create($request->validated());
return back()->with('status', 'Product created.');
}
}
@@ -0,0 +1,45 @@
<?php
namespace Modules\Products\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
final class StoreProductRequest extends FormRequest
{
public function authorize(): bool
{
return $this->user() !== null;
}
protected function prepareForValidation(): void
{
$this->merge([
'is_active' => $this->boolean('is_active'),
'is_featured' => $this->boolean('is_featured'),
'features' => collect(preg_split('/\r\n|\r|\n/', (string) $this->input('features')))
->map(fn (string $feature) => trim($feature))
->filter()
->values()
->all(),
]);
}
public function rules(): array
{
return [
'name' => ['required', 'string', 'max:255'],
'product_type' => ['required', 'in:product,plan'],
'description' => ['nullable', 'string'],
'price' => ['nullable', 'numeric', 'min:0'],
'currency' => ['required', 'string', 'size:3'],
'billing_period' => ['nullable', 'string', 'max:40'],
'features' => ['array'],
'features.*' => ['string', 'max:255'],
'cta_label' => ['nullable', 'string', 'max:80'],
'cta_url' => ['nullable', 'string', 'max:2048'],
'is_featured' => ['boolean'],
'sort_order' => ['integer', 'min:0'],
'is_active' => ['boolean'],
];
}
}