Laravel模块中的路由 [英] Routing in Laravel module

查看:502
本文介绍了Laravel模块中的路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Laravel 5中创建了一个模块,即在与app文件夹相同级别的内部,这是在Laravel中制作HMVC结构的一部分.我在模块文件夹中有两个模块,一个是项目文件夹,另一个是表单文件夹.现在,我在这些文件夹中找到了控制器,模型和视图.

I created a module in Laravel 5 i.e inside the same level as the app folder as part of making an HMVC structure in Laravel. I have two modules in the module folder, one being a project folder and another a form folder. Now I got the controller, model and view inside these folders.

单击此处查看文件夹结构

现在,当我尝试像

Route::controller('project/dashboard', 'ProjectController@index');

我遇到错误

ReflectionException in ControllerInspector.php line 35:
Class ProjectController does not exist

我想了解在Laravel中以模块化结构路由控制器的情况.

I would like to know about routing a controller in modular structure in Laravel.

推荐答案

使用Route::controller时使用此Route::controller('project/dashboard','ProjectController');

并在控制器内部定义

public function getIndex(){
    // write your code here
}

public function postIndex(){
    // write your code here
}
public function getCreate(){
    // write your code here
}

public function postStore(){
    // write your code here
}

这篇关于Laravel模块中的路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆