【问题标题】:How to redirect a laravel (5.3) Route with get parameters to other Route如何使用获取参数将 laravel (5.3) 路由重定向到其他路由
【发布时间】:2021-01-22 16:30:02
【问题描述】:

当有人打字时:

http://site/nota.php?id_nota=6

我需要重定向到:

http://site/nota/6

【问题讨论】:

  • 我试过了,但是有这个错误信息 Class 'Input' not found 我猜这是因为 laravel 版本...
  • 我正在尝试这个,但我已经收到一条错误消息
    code
    Route::get('nota.php', function ($request) {

    $id_nota=$request->input('id_nota');
    return redirect('nota',$id_nota);

    })-> name('notaphp');
    code
    错误信息返回:
    类型错误:函数 Illuminate\Routing\Router::{closure}() 的参数太少,传入 0 ...\vendor\laravel\framework\src\Illuminate\Routing\Route.php 在第 189 行,预期正好是 1

标签: laravel redirect parameters routes get


【解决方案1】:

好吧,我有一个解决方案,不是纯 laravel,而是可以工作

Route::get('/nota.php', function () {
    $id_nota = $_GET['id_nota'];

    return redirect()->route('nota', [$id_nota]);
})->name('notaphp');

【讨论】:

    猜你喜欢
    • 2017-04-01
    • 2017-04-17
    • 2017-04-12
    • 1970-01-01
    • 2015-06-16
    • 2021-11-07
    • 2019-02-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多