- Implemented CuttingIndex component for listing and managing cuttings. - Added routes for cutting management in web.php. - Created CuttingTest for testing cutting-related features including authorization, validation, and stock management. - Updated roles create and edit pages to include necessary imports. - Refactored settings and profile pages to streamline imports. - Enhanced permissions checks for cutting management actions.
74 lines
2.1 KiB
PHP
74 lines
2.1 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 Illuminate\Http\RedirectResponse;
|
|
use Inertia\Inertia;
|
|
use Inertia\Response;
|
|
|
|
class CuttingController extends Controller
|
|
{
|
|
public function __construct(
|
|
private CuttingService $service,
|
|
) {}
|
|
|
|
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', [
|
|
'data' => $this->service->getForCreate(),
|
|
]);
|
|
}
|
|
|
|
public function store(CuttingRequest $request): RedirectResponse
|
|
{
|
|
return $this->handleAction(
|
|
fn () => $this->service->create($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),
|
|
'data' => $this->service->getForCreate(),
|
|
]);
|
|
}
|
|
|
|
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->delete($cutting),
|
|
'Cutting berhasil dihapus.',
|
|
'admin.manage.cuttings.index'
|
|
);
|
|
}
|
|
}
|