- 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.
85 lines
2.5 KiB
PHP
85 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin\Manage;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Requests\Admin\Manage\RestockRequest;
|
|
use App\Http\Requests\PaginatedRequest;
|
|
use App\Models\Restock;
|
|
use App\Services\Admin\Manage\RestockService;
|
|
use App\Services\Admin\Master\Product\ProductVariantService;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Inertia\Inertia;
|
|
use Inertia\Response;
|
|
|
|
class RestockController extends Controller
|
|
{
|
|
public function __construct(
|
|
private RestockService $service,
|
|
private ProductVariantService $productVariantService,
|
|
) {}
|
|
|
|
public function index(PaginatedRequest $request): Response
|
|
{
|
|
return Inertia::render('admin/manage/restock/index', [
|
|
'restocks' => $this->service->paginated(
|
|
...$request->validatedWithDefaults(),
|
|
),
|
|
'highlight' => $request->input('highlight'),
|
|
]);
|
|
}
|
|
|
|
public function create(): Response
|
|
{
|
|
return Inertia::render('admin/manage/restock/create', [
|
|
'products' => $this->productVariantService->getForRestock(),
|
|
]);
|
|
}
|
|
|
|
public function store(RestockRequest $request): RedirectResponse
|
|
{
|
|
return $this->handleAction(
|
|
fn () => $this->service->store($request->validated()),
|
|
'Restock berhasil ditambahkan.',
|
|
'admin.manage.restocks.index',
|
|
'admin.manage.restocks.create'
|
|
);
|
|
}
|
|
|
|
public function edit(Restock $restock): Response
|
|
{
|
|
return Inertia::render('admin/manage/restock/edit', [
|
|
'restock' => $this->service->getForEdit($restock),
|
|
'products' => $this->productVariantService->getForRestock(),
|
|
]);
|
|
}
|
|
|
|
public function update(RestockRequest $request, Restock $restock): RedirectResponse
|
|
{
|
|
return $this->handleAction(
|
|
fn () => $this->service->update($restock, $request->validated()),
|
|
'Restock berhasil diperbarui.',
|
|
'admin.manage.restocks.index',
|
|
'admin.manage.restocks.edit',
|
|
['restock' => $restock]
|
|
);
|
|
}
|
|
|
|
public function destroy(Restock $restock): RedirectResponse
|
|
{
|
|
return $this->handleAction(
|
|
fn () => $this->service->destroy($restock),
|
|
'Restock berhasil dihapus.',
|
|
'admin.manage.restocks.index'
|
|
);
|
|
}
|
|
|
|
public function items(Restock $restock): JsonResponse
|
|
{
|
|
return response()->json([
|
|
'items' => $this->service->getItems($restock),
|
|
]);
|
|
}
|
|
}
|