【问题标题】:Symfony\Component\Routing\Exception\RouteNotFoundException: Route [Lala.search] not definedSymfony\Component\Routing\Exception\RouteNotFoundException: Route [Lala.search] 未定义
【发布时间】:2022-01-05 22:52:10
【问题描述】:

我创建了一个模型及其迁移,如下所示: php artisan make:模型拉拉-m 我做了这个:php artisan migrate

我打算把这条路称为这条路,但我搞错了。我写错了吗?提交表单时如何调用搜索方法?

公式:

<?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> 

我在 web.php 中定义了如下路由:

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

stipendiensController 是这样定义的:

<?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');
    }
}

如何避免这个错误?我可以用不同的方式编写这段代码吗?我确实尝试在我的搜索栏中输入数据,如果在搜索栏中输入的值在那里,我会在我的数据库中进行比较。 感谢你们对我的帮助 。请

【问题讨论】:

  • 第一步运行 php artisan route list 看看你的路由是否定义正确

标签: php laravel forms eloquent routes


【解决方案1】:

尝试像这样定义您的路线:

use App\Http\Controllers\stipendiensController;

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

【讨论】:

    猜你喜欢
    • 2021-11-24
    • 2022-12-16
    • 2021-09-10
    • 2012-08-09
    • 2022-12-05
    • 2019-08-02
    • 2021-05-28
    • 2020-05-15
    相关资源
    最近更新 更多