It's very important to access HTTP Request from Laravel Controller or Service. Below is a code example showing how to access HTTP Request from Laravel Controller. Same for Service.
<?php namespace App\Http\Controllers; use Illuminate\Http\Request as HttpRequest; use Illuminate\Routing\Controller as BaseController; class HomeController extends BaseController { private $HttpRequest; public function __construct(HttpRequest $HttpRequest) { $this->HttpRequest = $HttpRequest; } public function checkHttpRequest() { echo $this->HttpRequest->get("id") . "<BR>"; echo $this->HttpRequest->getBaseUrl() . "<BR>"; echo $this->HttpRequest->getUri(); die(); } }
No comments:
Post a Comment