Laravel将输入绑定到变量

时间:2018-01-20 08:23:14

标签: php laravel laravel-5.5

搜索整个互联网,发现没有相关内容。

我想从输入<input name="showLimit">

绑定paginate变量
public function index()
{
    $showLimit = Input::get('showLimit');
    $drivers = Driver::paginate($showLimit);
    return view('manage.driver', compact('drivers'));
}

错误:

  

Class'App \ Http \ Controllers \ Input'not found

2 个答案:

答案 0 :(得分:1)

Request class上使用依赖注入。

use Illuminate\Http\Request;

public function index(Request $request) {
    $showLimit = $request->get('showLimit');
    $drivers = Driver::paginate($showLimit);
    return view('manage.driver', compact('drivers'));
}

答案 1 :(得分:0)

似乎你有Input

的错误路径
$showLimit = Illuminate\Support\Facades\Input::get('showLimit');
$drivers = Driver::paginate($showLimit);
return view('manage.driver', compact('drivers'));