diff --git a/app/Domains/Catalog/routes/company.php b/app/Domains/Catalog/routes/company.php index 87666846..22854262 100644 --- a/app/Domains/Catalog/routes/company.php +++ b/app/Domains/Catalog/routes/company.php @@ -4,6 +4,10 @@ use App\Domains\Catalog\Http\Controllers\ItemsController; use App\Domains\Catalog\Http\Controllers\UnitsController; use Illuminate\Support\Facades\Route; -Route::post('/items/delete', [ItemsController::class, 'delete']); +Route::controller(ItemsController::class)->group(function () { + // Bulk removal is not one of the resource verbs, so it is declared on its + // own -- and ahead of them, to stay clear of the `items/{item}` patterns. + Route::post('items/delete', 'delete'); +}); Route::resource('items', ItemsController::class); Route::resource('units', UnitsController::class); diff --git a/app/Domains/Contacts/Http/Controllers/CustomerPortal/DashboardController.php b/app/Domains/Contacts/Http/Controllers/CustomerPortal/DashboardController.php index 8e64668e..7050f020 100644 --- a/app/Domains/Contacts/Http/Controllers/CustomerPortal/DashboardController.php +++ b/app/Domains/Contacts/Http/Controllers/CustomerPortal/DashboardController.php @@ -15,7 +15,7 @@ class DashboardController extends Controller ) {} /** - * Handle the incoming request. + * Answer with the portal dashboard figures for the signed-in contact. * * @return Response */ diff --git a/app/Domains/Contacts/Http/Controllers/CustomerPortal/ProfileController.php b/app/Domains/Contacts/Http/Controllers/CustomerPortal/ProfileController.php index a70b5d06..a3530019 100644 --- a/app/Domains/Contacts/Http/Controllers/CustomerPortal/ProfileController.php +++ b/app/Domains/Contacts/Http/Controllers/CustomerPortal/ProfileController.php @@ -9,7 +9,6 @@ use App\Domains\Contacts\Http\Requests\CustomerPortal\CustomerProfileRequest; use App\Domains\Contacts\Http\Resources\CustomerPortal\CustomerResource; use App\Platform\Http\Controller; use Illuminate\Http\Request; -use Illuminate\Support\Facades\Auth; class ProfileController extends Controller { @@ -20,7 +19,7 @@ class ProfileController extends Controller public function updateProfile(Company $company, CustomerProfileRequest $request) { - $customer = Auth::guard('customer')->user(); + $customer = auth('customer')->user(); $customer = $this->customerService->updateProfile( customer: $customer, @@ -43,13 +42,11 @@ class ProfileController extends Controller ); } - return new CustomerResource($customer); + return CustomerResource::make($customer); } public function getUser(Request $request) { - $customer = Auth::guard('customer')->user(); - - return new CustomerResource($customer); + return CustomerResource::make(auth('customer')->user()); } } diff --git a/app/Domains/Contacts/routes/company.php b/app/Domains/Contacts/routes/company.php index 86af98a3..f5a9fac6 100644 --- a/app/Domains/Contacts/routes/company.php +++ b/app/Domains/Contacts/routes/company.php @@ -4,6 +4,16 @@ use App\Domains\Contacts\Http\Controllers\Company\CustomersController; use App\Domains\Contacts\Http\Controllers\Company\CustomerStatsController; use Illuminate\Support\Facades\Route; -Route::post('/customers/delete', [CustomersController::class, 'delete']); -Route::get('customers/{customer}/stats', CustomerStatsController::class); -Route::resource('customers', CustomersController::class); +// The two endpoints that hang off the contacts collection but are not part of +// its resource. Both are declared first, so the literal "delete" segment can +// never be read as a {customer} key. +Route::prefix('customers')->group(function () { + Route::post('delete', [CustomersController::class, 'delete']); + Route::get('{customer}/stats', CustomerStatsController::class); +}); + +// Contact CRUD, as a full resource rather than an API one — the create and +// edit routes stay in the table even though the SPA never calls them. +Route::resources([ + 'customers' => CustomersController::class, +]); diff --git a/app/Domains/Contacts/routes/customer.php b/app/Domains/Contacts/routes/customer.php index f4ce4f48..09b2a970 100644 --- a/app/Domains/Contacts/routes/customer.php +++ b/app/Domains/Contacts/routes/customer.php @@ -6,8 +6,8 @@ use App\Domains\Contacts\Http\Controllers\CustomerPortal\DashboardController; use App\Domains\Contacts\Http\Controllers\CustomerPortal\ProfileController; use Illuminate\Support\Facades\Route; -Route::get('/bootstrap', BootstrapController::class); -Route::get('/dashboard', DashboardController::class); +Route::get('bootstrap', BootstrapController::class); // everything the portal SPA needs at boot +Route::get('dashboard', DashboardController::class); // landing figures for the signed-in contact Route::post('/profile', [ProfileController::class, 'updateProfile']); Route::get('/me', [ProfileController::class, 'getUser']); -Route::get('/countries', CountriesController::class); +Route::get('countries', CountriesController::class); // country list behind the address fields diff --git a/app/Domains/Contacts/routes/public.php b/app/Domains/Contacts/routes/public.php index 5dd450f7..b3d2d01d 100644 --- a/app/Domains/Contacts/routes/public.php +++ b/app/Domains/Contacts/routes/public.php @@ -3,4 +3,4 @@ use App\Domains\Contacts\Http\Controllers\CountriesController; use Illuminate\Support\Facades\Route; -Route::get('/countries', CountriesController::class); +Route::get('countries', CountriesController::class); // country list for the guest-facing forms