I'm new in laravel, I wants to make separate folder for admin & front end. I've made folder like this
app/http/Controllers/Catalog/Common/home.php
app/http/Controllers/Admiin/Common/home.php
I wants to place common controllers in common folder like header, footer etc. In any another folder will be another related files like eg: category
app/http/Controllers/Catalog/Category/list.php
app/http/Controllers/Catalog/Category/product.php
app/http/Controllers/Admiin/Category/list.php
app/http/Controllers/Admiin/Category/categoryForm.php
But I'm stuck to make it working with routes, Should I use the same logic in Laravel or is there a better way to do it? Please suggest me how can I do it?
Here are the first four lines of my home controller
namespace LocalProject\Http\Controllers\Catalog\Common;
use Illuminate\Http\Request;
use LocalProject\Http\Requests;
use LocalProject\Http\Controllers\Controller;
I'd really appreciate any kind of help.
Routes work based off of namespaces, class names, and functions.
\\Namespace\\Classname@functionName
Folder structure shouldn't matter.
Edit for some more question specific answers:
You probably want to use something like this:
Route::get("home/index", [ "as" => "home.index", "uses" => "\LocalProject\Http\Controllers\Catalog\Common\HomeController" => "HomeController@index" ]);
You may also want to look into Route::group
to help keep your namespaces more organized.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.