skip to Main Content

Route [paslon.create] not defined.

<a href="{{route('daftar.create')}}" class="btn btn-primary btn-sm mb-3">tambah1</a>

controller

public function create()
    {
        return view('daftar.create');
    }

web.php

Route::get('/create', function () { return view('/daftar/create'); });

my solution is changing in <a href="/create" class="btn btn-primary btn-sm mb-3">tambah1</a>

and in web Route::get('/create', function () { return view('daftar.create'); });

but I don’t know if it will be safe or not


2

Answers


  1. You’re calling route with name and for that you have to define name first in the routes/web.php

    Route::get('/create', function () { 
       return view('/daftar/create'); 
    })->name('daftar.create');
    

    For more better understanding checkout the documentation:

    https://laravel.com/docs/10.x/routing#named-routes

    Login or Signup to reply.
  2. By default your routes doesn’t have any name, you can see it typing in console:

    php artisan route:list
    

    You will see route names.
    You need to declare name yourself

    Route::get('/create', function () { return view('/daftar/create'); })->name('daftar.create');
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search