Symfony\Component\Routing\Exception\RouteNotFoundException: Route [Lala.search] not defined

Viewed 887

I created a model and its migration like this: php artisan make:model Lala -m And I made this : php artisan migrate

I was going to call this road, but I have a mistake. Did I write it wrong? How can I call the search method when my form is submitted?

formular:

<?php
use App\Models\Lala;
?>

<form  action="{{ route('Lala.search')}}" method="GET" >
 <div class="input-group mb-3">
  <input type="text"
    name="name" class="form-control" placeholder="Geben Sie etwas an"
    aria-label="Geben Sie etwas an"
  aria-describedby="basic-addon2" autocomplete="off">
  <div class="input-group-append">
  <span class="input-group-text" id="basic-addon2"></span>
</div>
</div>
<input type="submit" class="btn btn-primary" value="search">
</form> 

I defined the route as follows in web.php :

use App\Models\Lala;
Route::get('/search',[
'as' =>'Lala.search',
'uses' =>'\App\Http\Controllers\stipendiensController@search']);

stipendiensController is defined like this:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Models\Stipendien;

class stipendientsController extends Controller
{
public $name;

 public function search()
    {
return view('seite.Stipendien');
    }
}

how to avoid this error? could I write this code differently? I try indeed to enter the data in my search bar and I compare in my database if the value entered in the search bar is there. Thank you for helping me . Please

1 Answers

Try defineing your route like so:

use App\Http\Controllers\stipendiensController;

Route::get('/search', [stipendiensController::class, 'search'])
    ->name('Lala.search');
Related