public function store(Request $request)
{
//验证规则
$this->validate($request, [
'title' => 'required|min:3',
'content' => 'required',
'published_at' => 'required',
]);
$input = $request::all();
//下面增加两行,顺便看看$request::get的使用
$input['intro'] = mb_substr($request::get('content'), 0, 64);
//$input['published_at'] = Carbon::now();
Article::create($input);
return redirect('/articles');
}
具体代码如上,以为为提示错误:
ErrorException in ValidatesRequests.php line 30:
Argument 1 passed to App\Http\Controllers\Controller::validate() must be an instance of Illuminate\Http\Request, instance of Illuminate\Support\Facades\Request given, called in /Users/yuzhibiao/Code/www.laravel.org/Laravel5-1-20/app/Http/Controllers/ArticlesController.php on line 48 and defined