Skip to content

Commit

Permalink
Merge pull request #2 from hotwired-laravel/tm/tweaks-routes
Browse files Browse the repository at this point in the history
Use singleton routes
  • Loading branch information
tonysm authored Dec 1, 2023
2 parents 902b2c9 + 67078db commit 59e18f8
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 13 deletions.
6 changes: 3 additions & 3 deletions stubs/turbo/app/Http/Controllers/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
class ProfileController extends Controller
{
/**
* Display the user's profile index menu.
* Display the user's profile menu.
*/
public function index(Request $request): View
public function show(Request $request): View
{
return view('profile.index', [
return view('profile.show', [
'user' => $request->user(),
]);
}
Expand Down
2 changes: 1 addition & 1 deletion stubs/turbo/resources/views/layouts/navigation.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class="group bg-white dark:bg-gray-800 border-b border-gray-100 dark:border-gray

<div class="flex items-center space-x-2">
<!-- Settings Dropdown -->
<a href="{{ route('profile.index') }}" class="inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md text-gray-500 dark:text-gray-400 bg-white dark:bg-gray-800 hover:text-gray-700 dark:hover:text-gray-300 focus:outline-none transition ease-in-out duration-150">
<a href="{{ route('profile.show') }}" class="inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md text-gray-500 dark:text-gray-400 bg-white dark:bg-gray-800 hover:text-gray-700 dark:hover:text-gray-300 focus:outline-none transition ease-in-out duration-150">
<div>{{ Auth::user()->name }}</div>
</a>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<x-app-layout>
<x-slot name="header">
<h2 class="font-semibold text-xl text-gray-800 dark:text-gray-200 leading-tight">
<x-breadcrumbs :links="[route('profile.index') => __('Profile & Settings'), __('Change Password')]" />
<x-breadcrumbs :links="[route('profile.show') => __('Profile & Settings'), __('Change Password')]" />
</h2>
</x-slot>

Expand Down
2 changes: 1 addition & 1 deletion stubs/turbo/resources/views/profile/delete.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<x-app-layout>
<x-slot name="header">
<h2 class="font-semibold text-xl text-gray-800 dark:text-gray-200 leading-tight">
<x-breadcrumbs :links="[route('profile.index') => __('Profile & Settings'), __('Delete Account')]" />
<x-breadcrumbs :links="[route('profile.show') => __('Profile & Settings'), __('Delete Account')]" />
</h2>
</x-slot>

Expand Down
2 changes: 1 addition & 1 deletion stubs/turbo/resources/views/profile/edit.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<x-app-layout>
<x-slot name="header">
<h2 class="flex items-center space-x-1 font-semibold text-xl text-gray-800 dark:text-gray-200 leading-tight">
<x-breadcrumbs :links="[route('profile.index') => __('Profile & Settings'), __('Edit Profile')]" />
<x-breadcrumbs :links="[route('profile.show') => __('Profile & Settings'), __('Edit Profile')]" />
</h2>
</x-slot>

Expand Down
10 changes: 4 additions & 6 deletions stubs/turbo/routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@
})->middleware(['auth', 'verified'])->name('dashboard');

Route::middleware('auth')->group(function () {
Route::get('/profile', [ProfileController::class, 'index'])->name('profile.index');
Route::singleton('profile', ProfileController::class);

Route::get('/profile/edit', [ProfileController::class, 'edit'])->name('profile.edit');
Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update');

Route::get('/profile/password/edit', [ProfilePasswordController::class, 'edit'])->name('profile.password.edit');
Route::patch('/profile/password', [ProfilePasswordController::class, 'update'])->name('profile.password.update');
Route::prefix('profile')->as('profile.')->group(function () {
Route::singleton('password', ProfilePasswordController::class)->only(['edit', 'update']);
});

Route::get('/profile/delete', [ProfileController::class, 'delete'])->name('profile.delete');
Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy');
Expand Down

0 comments on commit 59e18f8

Please sign in to comment.