I'm new to Laravel and having trouble with subdirectories. I want to make an admin folder inside the controllers folder and so far it's working. but when I try to use Laravel's Input class it says that it couldn't find it.
My routes:
Route::group(array('prefix'=> 'admin', 'before' => 'auth.admin'), function() {
Route::resource('/users','Admin\\UsersController');
Route::resource('/products','Admin\\ProductsController');
Route::resource('/categories','Admin\\CategoriesController');
Route::resource('/orders','Admin\\OrdersController');
Route::resource('/reviews','Admin\\ReviewsController');
});
The Products Controller:
<?php namespace admin;
class ProductsController extends \BaseController {
protected $layout = 'master';
/**
* Instantiate a new ProductsController instance.
*/
public function __construct()
{
$this->beforeFilter('auth.admin');
}
/**
* Display a listing of the resource.
* GET /products
*
* @return Response
*/
public function index()
{
$input = Input::all(); //here is where it finds the error
And the composer.json autoload:
"autoload": {
"classmap": [
"app/commands",
"app/controllers/",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php",
"app/controllers/Admin"
]
},
Thank you!
Edit:
I have also tried to use Input (and \Input) and it returned the "Class 'Facade' not found" error, and when I tried:
use \Illuminate\Support\Facades\Facade;
use Input;
It still did not work.
Edit 2:
Now using:
use Illuminate\Support\Facades\Input;
and returning the same error.
Edit 3: Did the modifications suggested by @ChristopherRathgeb and now it's not finding the products model.
Answer:
After doing the modifications suggested by @ChristopherRathgeb and adding \ to the View and Input classes(example $input = \Input:all();) it worked! And now to redirect to these controller with the action method I just used action(admin\ProductsController) and it worked!
My thanks to all who helped!
useInput or Facade as they should be automatically registered as soon as the app is started. Did youcomposer dump-autoloadafter moving the controllers into the subdirectory?composer dump-autoloadsuccessfully, but it's still not working (and driving me crazy haha)