- Updated CustomerService to simplify getAll method. - Refactored ProductService to utilize HasRoleChecks trait and improved role verification logic. - Enhanced ProductVariantService with new methods for fetching data for restocking and transactions. - Cleaned up RawMaterialService by removing unused methods and improving data retrieval. - Adjusted SupplierService to streamline getAll method. - Refactored RoleService to use Spatie's Role model and improved role filtering logic. - Updated NotificationService to handle role labels more effectively. - Improved StockMutationService by removing redundant paginated method. - Cleaned up various frontend components to directly accept necessary props instead of nested data objects. - Updated tests to reflect changes in service method names and ensure proper notification handling.
76 lines
2.3 KiB
PHP
76 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin\Manage;
|
|
|
|
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\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(),
|
|
),
|
|
]);
|
|
}
|
|
|
|
public function create(): Response
|
|
{
|
|
return Inertia::render('admin/manage/cutting/create', [
|
|
'rawMaterials' => $this->rawMaterialVariantService->getForCutting(),
|
|
]);
|
|
}
|
|
|
|
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'
|
|
);
|
|
}
|
|
}
|