2

Hi in my project there are many controllers and i want use input everywhere without including in controller at top like this

use Illuminate\Support\Facades\Input; //or 
use Input; // if i create alias for the same in app.php

is there any way that without include i get input in whole system without including in all controller at top ?

Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291
Darshan ambaliya
  • 301
  • 3
  • 20
  • 1
    probably too short for an answer but: you could create a generic controller for your application, and have all of your subsequent controllers inherit from it. – William Perron Dec 21 '17 at 13:06

1 Answers1

1

As far as I know it's impossible. This is how PHP namespaces work, you should import them in each file.

About Input in fact it's Laravel 4 way, you don't use input now, you use Illuminate\Http\Request in Laravel 5. Additionally you can not import this class if you are fine with using Laravel request() helper, so in controller do get all the data from request/input you can now use:

$data = request()->all();
Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291