feat: mendifinisikan roite barbershop dan menggunakan explicit route model binding
This commit is contained in:
parent
cb3654a54f
commit
15b5f7ae0d
26
app/Providers/RouteServiceProvider.php
Normal file
26
app/Providers/RouteServiceProvider.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Models\Barbershop;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register services.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
Route::bind('barbershop', fn (string $barbershop) => Barbershop::findOrFail(decryptId($barbershop)));
|
||||
}
|
||||
}
|
||||
@ -2,4 +2,5 @@
|
||||
|
||||
return [
|
||||
App\Providers\AppServiceProvider::class,
|
||||
App\Providers\RouteServiceProvider::class,
|
||||
];
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
use App\Http\Controllers\Admin\Auth\LoginController;
|
||||
use App\Http\Controllers\Admin\Dashboard\OverviewController;
|
||||
use App\Http\Controllers\Admin\Master\BarbershopController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::prefix('auth')->group(function () {
|
||||
@ -12,6 +13,20 @@
|
||||
Route::get('forgot-password', [LoginController::class, 'forgotPassword'])->name('auth.forgot-password');
|
||||
});
|
||||
|
||||
Route::prefix('dashboard')->group(function () {
|
||||
Route::group([
|
||||
'middleware' => 'auth',
|
||||
'prefix' => 'dashboard',
|
||||
], function () {
|
||||
Route::get('overview', [OverviewController::class, 'index'])->name('dashboard.overview');
|
||||
|
||||
Route::prefix('master')->group(function () {
|
||||
Route::prefix('barbershop')->group(function () {
|
||||
Route::get('/', [BarbershopController::class, 'index'])->name('master.barbershop');
|
||||
Route::get('create', [BarbershopController::class, 'create'])->name('master.barbershop.create');
|
||||
Route::post('store', [BarbershopController::class, 'store'])->name('master.barbershop.store');
|
||||
Route::get('edit/{barbershop}', [BarbershopController::class, 'edit'])->name('master.barbershop.edit');
|
||||
Route::put('update/{barbershop}', [BarbershopController::class, 'update'])->name('master.barbershop.update');
|
||||
Route::delete('delete/{barbershop}', [BarbershopController::class, 'delete'])->name('master.barbershop.delete');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user