- Updated paginated methods in multiple services to accept a highlight parameter for filtering results. - Modified notification URLs to include the highlight parameter for specific entity IDs. - Enhanced frontend components to display a message when filtered by notification, with an option to show all entries. - Implemented mark as read functionality in the notification bell component upon clicking a notification. - Updated multiple index pages to handle the highlight prop and display relevant messages.
116 lines
3.6 KiB
PHP
116 lines
3.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin\Manage;
|
|
|
|
use App\Enums\CuttingStatus;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Requests\Admin\Manage\CuttingRequest;
|
|
use App\Http\Requests\PaginatedRequest;
|
|
use App\Models\Cutting;
|
|
use App\Services\Admin\Manage\CuttingService;
|
|
use App\Services\Admin\Master\RawMaterial\RawMaterialVariantService;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Inertia\Inertia;
|
|
use Inertia\Response;
|
|
|
|
class CuttingController extends Controller
|
|
{
|
|
public function __construct(
|
|
private CuttingService $service,
|
|
private RawMaterialVariantService $rawMaterialVariantService,
|
|
) {}
|
|
|
|
public function index(PaginatedRequest $request): Response
|
|
{
|
|
return Inertia::render('admin/manage/cutting/index', [
|
|
'cuttings' => $this->service->paginated(
|
|
...$request->validatedWithDefaults(),
|
|
filters: $request->only(['product_name', 'status']),
|
|
),
|
|
'filters' => $request->only(['product_name', 'status']),
|
|
'filterOptions' => [
|
|
'statusOptions' => CuttingStatus::toSelect(),
|
|
'productNames' => $this->service->getProductNames(),
|
|
],
|
|
'highlight' => $request->input('highlight'),
|
|
]);
|
|
}
|
|
|
|
public function create(): Response
|
|
{
|
|
return Inertia::render('admin/manage/cutting/create', [
|
|
'rawMaterials' => $this->rawMaterialVariantService->getForCutting(),
|
|
]);
|
|
}
|
|
|
|
public function show(Cutting $cutting): Response
|
|
{
|
|
return Inertia::render('admin/manage/cutting/show', [
|
|
'cutting' => $this->service->getForShow($cutting),
|
|
]);
|
|
}
|
|
|
|
public function share(Cutting $cutting): Response
|
|
{
|
|
return Inertia::render('admin/manage/cutting/show', [
|
|
'cutting' => $this->service->getForShow($cutting),
|
|
]);
|
|
}
|
|
|
|
public function store(CuttingRequest $request): RedirectResponse
|
|
{
|
|
return $this->handleAction(
|
|
fn () => $this->service->store($request->validated()),
|
|
'Cutting berhasil ditambahkan.',
|
|
'admin.manage.cuttings.index',
|
|
'admin.manage.cuttings.create'
|
|
);
|
|
}
|
|
|
|
public function edit(Cutting $cutting): Response
|
|
{
|
|
return Inertia::render('admin/manage/cutting/edit', [
|
|
'cutting' => $this->service->getForEdit($cutting),
|
|
'rawMaterials' => $this->rawMaterialVariantService->getForCutting(),
|
|
]);
|
|
}
|
|
|
|
public function update(CuttingRequest $request, Cutting $cutting): RedirectResponse
|
|
{
|
|
return $this->handleAction(
|
|
fn () => $this->service->update($cutting, $request->validated()),
|
|
'Cutting berhasil diperbarui.',
|
|
'admin.manage.cuttings.index',
|
|
'admin.manage.cuttings.edit',
|
|
['cutting' => $cutting]
|
|
);
|
|
}
|
|
|
|
public function destroy(Cutting $cutting): RedirectResponse
|
|
{
|
|
return $this->handleAction(
|
|
fn () => $this->service->destroy($cutting),
|
|
'Cutting berhasil dihapus.',
|
|
'admin.manage.cuttings.index'
|
|
);
|
|
}
|
|
|
|
public function complete(Cutting $cutting): RedirectResponse
|
|
{
|
|
return $this->handleAction(
|
|
fn () => $this->service->complete($cutting),
|
|
'Cutting berhasil diselesaikan.',
|
|
'admin.manage.cuttings.index'
|
|
);
|
|
}
|
|
|
|
public function materials(Cutting $cutting): JsonResponse
|
|
{
|
|
return response()->json([
|
|
'materials' => $this->service->getMaterials($cutting),
|
|
'combinations' => $this->service->getCombinations($cutting),
|
|
]);
|
|
}
|
|
}
|