php - Laravel Request input() or get() -


with laravel 5 seems method injection request object preferred on using request facade.

<?php namespace app\http\controllers;  use illuminate\http\request;  class homecontroller extends controller {     public function index(request $request)     {         $email = $request->input('email');          // or          $email = $request->get('email');     } } 

a few questions have:

is using illuminate\http\request better using illuminate\support\facades\request

i have no idea how $request->get() resolving there no function name get() in illuminate\http\request. input() , get() same thing.

is method injection better using facades?

in controller method request injection functionality preferable, because in methods use form requests (they extending default request class) validation, validate request automatically before entering actual controller method. awesome feature helps create slim , clean controller's code.

using default request injection makes controller's methods similar , easier maintain.

also object injection better facades, because such methods & objects easier test.

get() andinput() methods of different classes. first 1 method of symphony httpfoundation request, input() method of laravel request class extending symphony request class.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -