HTTP Request vs request()

Posted 1 year ago by tiagomatosweb

Hey all, Just wondering what is the best practice for getting the request information. Lets say a have the scenario bellow

Scenario 1

// controller
public function store(MyRequest $request) {

// MyRequest.php
class MyRequest extends FormRequest
    public function rules()
        return [
            'field'     => 'required|string',
            'field'    => 'required|string',
            'field'    => 'required|string',
            'field'          => 'required|integer',

Scenario 2

public function store() {
   $request = request()->only(['field', 'field', 'field']);

Thank you

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.