简体   繁体   中英

How to call BaseController methods on admin controller in laravel4 without backslash?

I have admin following structure:

Controller->admin->logincontroller
Model->admin->
View->admin->

I have used basecontroller using backslash like

namespace admin;
class LoginController extends \BaseController {

However I need to place backslash on every method of base controller like as

return \View::make('test'); //instead of return View::make('');
 \Input::get('test') // instead of Input::get('username');
\Session::put() //Instead of Session::put();
etc...

So what is solutions to access method without backslash before every method repeatability.

You can use method direct without '\\' into latest version. No need to add '\\' before method into controller.

This is because you use the namespace admin. Now he will search the methods inside the admin namespace and not withing the global namespace.

You could also define the fullpath of those functions if you want to avoid \\ but what \\ does is saying "use the global namespace path" instead of the defined above namespace.

namespace fallback in PHP

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM