Laravel 4 Undefined offset:0(查看:users.blade.php)

时间:2014-06-27 17:53:48

标签: php laravel laravel-4 cartalyst-sentry

我始终出现此错误Undefined offset: 0 (View: users.blade.php)

以下是index()UserController的代码:

public function index() {
        // try{
            // Find the user using the user id
            $user = Sentry::getUser();

            // Find the Administrator group
            $admin = Sentry::findGroupByName('admin');

            $groups = array();
            foreach (Sentry::findAllGroups() as $groupObj) {
                $groups[$groupObj->id] = $groupObj->name;
            }
            // Check if the user is in the administrator group
            // if ($user->inGroup($admin))
            // {
                // User is in Administrator group
                return View::make('edit.users')->with('groups',$groups);
        //     }
        //     else
        //     {
        //         // User is not in Administrator group
        //         return View::make('layout');
        //     }
        // }
        // catch (Cartalyst\Sentry\Users\UserNotFoundException $e)
        // {
        //     echo 'User was not found.';
        // }
        // catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e)
        // {
        //     echo 'Group was not found.';
        // }        
    }

我评论过的评论和评论没有任何区别。

以下是routes.php

Route::group(array('before'=>'auth'),function() {
    Route::resource('admin', 'UserController');
    Route::resource('admin/typ', 'TypeController');
    Route::resource('admin/cat', 'CategoryController');
    Route::resource('admin/group', 'GroupController');
    Route::get('logout', 'HomeController@logout');
});

Route::get('register', 'HomeController@getRegister');
Route::get('login', 'HomeController@getLogin');
Route::post('login', 'HomeController@postLogin');
Route::post('register', 'UserController@store');

0 个答案:

没有答案