PLATFORM
  • Tails

    Create websites with TailwindCSS

  • Blocks

    Design blocks for your website

  • Wave

    Start building the next great SAAS

  • Pines

    Alpine & Tailwind UI Library

  • Auth

    Plug'n Play Authentication for Laravel

  • Designer comingsoon

    Create website designs with AI

  • DevBlog comingsoon

    Blog platform for developers

  • Static

    Build a simple static website

  • SaaS Adventure

    21-day program to build a SAAS

Question By

Solved

How Do You Add Routes to Custom Files

Solved
elkinkm97

Nov 7th, 2022 08:57 PM

Hello everyone, So I'm trying to add a new custom page where after going to the dashboard and processing a task, it navigates to a new page (i.e dashboard.php -> result.php). I saw online that I would need to make some changes to web.php file in the routes folder, but I keep running into errors with syntax or page not existing. Does anyone have resources or instructions on how to add a new custom route to a wave application? Thank you!

bobbyiliev

Nov 7th, 2022 11:28 PM

Best Answer

Hi there,

You can add a route to Wave just as you would for any other standard Laravel app.

You can do the following:

  • Create a Controller:
php artisan make:controller YourController

Change YourController with a descritive name of the thing that your controller will be doing.

  • Then open the Controller file (app/Http/Controllers/YourController.php), and define your method, for example:
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class YourController extends Controller
{
    public function index()
    {
        return view('your-view');
    }
}
  • After that create your blade view in the resources/views directory, make sure that it ends with .blade.php

  • Then in your routes/web.php file add the route definition:

use App\Http\Controllers\YourController;
Route::get('/your-route', [YourController::class, 'index']);

Make sure to go through the introduction to Laravel course here:

https://devdojo.com/course/laravel-7-basics

And also check out the documentation here:

https://laravel.com/docs/9.x/routing

Let me know if you have any questions.

elkinkm97

Nov 10th, 2022 01:49 PM

That solved the problem, thank you for helping!