dimanche 23 septembre 2018

Why use dependency injection for Request object vs request() helper in Laravel?

Is there any benefit to injecting the Request object into your controller method like this:

use Request;

class WidgetController
{
  public function create(Request $request)
  {
    $name = $request->input('name');
  }
}

Versus eliminating the use statement and object injection and simply using the helper:

class WidgetController
{
  public function create()
  {
    $name = request('name');
  }
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire