题
我是 Laravel 的新手。我在尝试使用路线和控制器时遇到了这个问题。我有这个控制器
class DashboardController extends BaseController {
public function actionIndex()
{
$photos = Auth::user()->photos()->orderBy('created_at', 'desc')->orderBy('id', 'desc')->get();
return View::make('dashboard.index', array('photos' => $photos));
}
public function action_insert_test_data()
{
$logged_in_user = Auth::user();
for( $x = 0; $x < 10; $x++ ) {
$email = rand().'@gmail.com';
$user = new User();
$user->email = $email;
$user->password = Hash::make($email);
$user->save();
$logged_in_user->followers()->attach($user->id);
if( $x >= 5 ) {
$logged_in_user->following()->attach($user->id);
}
}
}
我尝试将此控制器中的所有操作路由到仪表板页面
Route::controller('dashboard', 'DashboardController');
但我没有工作,而是收到了这样的错误消息
Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException
我应该怎么办?我哪里做错了?我正在使用Laravel 4.1感谢您的关注
解决方案
你的类中的方法应该被命名 getIndex
和 getInsertTestData
.
不隶属于 StackOverflow