Reputation: 1041
I have a function in my controller. The problem is I must use two Requests at the same time but only one of them can be used in a controller.
Code:
public function func(Request $req) {
if (Request::isMethod('post')) {
$this->validate($req, [
'username' => 'required|string'
]);
}
}
What is the solution?
Upvotes: 2
Views: 1430
Reputation: 7303
If you wanted to use both of them, you can alias them as below:
use Illuminate\Http\Request as RequestNew;
use Illuminate\Support\Facades\Request as RequestOld;
And then you can reference the alias in your code.
eg: RequestNew::isMethod('post')
Upvotes: 3