Support the ongoing development of Laravel.io →
Requests Input Forms

Im new to Laravel, and thought i would start out by creating a simple form. By searching around the internet, i've stumbled upon two ways of doing this, and i want to know which way is the right way or "best practice" way of doing things around here.

First of all i have a simple form

<form method="POST" action="/admin/product/save" class="form-horizontal" enctype="multipart/form-data" role="form">....</form>

Then i have a route that calls a method in my product controller

Route::post('/admin/product/save', 'ProductController@add');

And then comes my question. The method i have called "add" can handle the input in two ways. One being this way requring me to declare the "use Input" in top of the controller file:

use Input;
...

public function add()
{
    return Input::all();
    ...
}

And then there is this way

public function add(Request $request)
{
    return $request;
}

But what of these methods are considered the most correct way?

Last updated 2 years ago.
0

i dont think it matters as long as you are consistent and know what is happening..

0

I switched to the second version because I like to use FormRequests as Validation. Since I typehint the FormRequest anyway I have access to all the parameters through the $request object too.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.