laravel请求表单验证
作者:互联网
laravel请求表单验证
定义路由
首先,我们假定在 routes/web.php 文件中包含如下路由:
1
// 显示创建博客文章表单...
2
Route::get('post/create', 'PostController@create');
3
// 存储新的博客文章...
Route::post('post', 'PostController@store');
2,创建控制器
php artisan make:controller IndexController
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class IndexController extends Controller
{
//
public function formm(){
return view('formm');
}
public function store(Request $request){
//dd($request->all());
$validatedData = $request->validate([
'title' => 'required|max:255',
'body' => 'required',
]);
return 'www.96net.com.cn';
}
}
标签:laravel,Http,验证,request,formm,表单,post,IndexController 来源: https://www.cnblogs.com/96net/p/15801749.html