获取 HTTP 请求的实例

要获取 HTTP 请求的实例,类 Illuminate\Http\Request 需要在构造函数或控制器的方法中键入提示。

示例代码:

 <?php

namespace App\Http\Controllers;

/* Here how we illuminate the request class in controller */
use Illuminate\Http\Request; 

use Illuminate\Routing\Controller;

class PostController extends Controller
{
 /**
  * Store a new post.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $name = $request->input('post_title');

     /*
     * so typecasting Request class in our method like above avails the
     * HTTP GET/POST/PUT etc method params in the controller to use and 
     * manipulate
     */
 }
}