Customizing the Two-Factor Authentication
First off, thank you for developing Wave—I've really enjoyed learning Laravel through it, and I'm even considering building something with it! I do have a small question, though. On the two-factor authentication page, I'm trying to modify the Blade template to add a return button or remove a line—just some small adjustments. However, I haven’t quite figured it out. Thanks!
Hey!
Happy to hear that you are having a good experience with Wave and Laravel so far!
Wave uses the Auth package here:
It uses Folio and Volt.
You can't directly modify those views, but you can override a view from the devdojo/auth
package without editing the vendor files, follow these steps:
Step 1: Locate the Route
Use the php artisan folio:list
command to find the route and associated view file:
php artisan folio:list | grep two-factor
For example, if the output shows:
GET /user/two-factor-authentication user.two-factor-authentication › vendor/devdojo/auth/resources/views/pages/user/two-factor-authentication/index.blade.php
This tells you that the route and its corresponding view file are defined in the package.
Step 2: Copy the Vendor View to Your Project
Create the necessary directories in your resources/views
folder and copy the original Blade file:
mkdir -p resources/views/pages/user/two-factor-authentication
cp vendor/devdojo/auth/resources/views/pages/user/two-factor-authentication/index.blade.php resources/views/pages/user/two-factor-authentication/index.blade.php
Step 3: Override the Route
To use your custom view instead of the package's, add this to your routes/web.php
file:
Route::view('/user/two-factor-authentication', 'pages/user/two-factor-authentication/index');
This will force Laravel to use your customized view located at resources/views/pages/user/two-factor-authentication/index.blade.php
.
Notes:
-
- You can use this approach for other routes as well by finding the corresponding route and view file using
php artisan folio:list
.
- You can use this approach for other routes as well by finding the corresponding route and view file using
- By overriding the route and copying the view, you can safely customize the package's functionality without directly modifying its files, making future updates easier.
Hope that this helps!
- Bobby
Or if we want to override to a theme view (instead of just a view) we can use theme::<path to blade file>
for example to override the registration page with a theme specific page view use:
Route::view('/auth/register', 'theme::pages/auth/register');
(tested ok just not sure if its 100% clean/recommended)
















Neat! This also looks good! Thanks for sharing it!