Laravel:将索引重定向到另一个索引。从路线或控制器呼叫路线?

时间:2015-01-12 17:46:25

标签: laravel

我定义了一堆路线

# Programs Management
Route::resource('programs', 'AdminProgramController');

Route::resource('scheduled_programs', 'AdminScheduledProgramController');

Route::resource('attendees', 'AdminAttendeeController');

# User Management
Route::get('users/{user}/show', 'AdminUsersController@getShow');
Route::get('users/{user}/edit', 'AdminUsersController@getEdit');
Route::post('users/{user}/edit', 'AdminUsersController@postEdit');
Route::get('users/{user}/delete', 'AdminUsersController@getDelete');
Route::post('users/{user}/delete', 'AdminUsersController@postDelete');
Route::controller('users', 'AdminUsersController');

# User Role Management
Route::get('roles/{role}/show', 'AdminRolesController@getShow');
Route::get('roles/{role}/edit', 'AdminRolesController@getEdit');
Route::post('roles/{role}/edit', 'AdminRolesController@postEdit');
Route::get('roles/{role}/delete', 'AdminRolesController@getDelete');
Route::post('roles/{role}/delete', 'AdminRolesController@postDelete');
Route::controller('roles', 'AdminRolesController');

# Admin Dashboard
Route::controller('/', 'AdminDashboardController');

看起来很整洁,但我知道我的/路线现在只指向scheduled_programs。我可能会稍后改变它指向另一条路线,但它可能永远不会需要它自己的观点。

class AdminDashboardController extends AdminController {

/**
 * Admin dashboard
 *
 */
public function getIndex()
{
    return View::make('admin/dashboard');
}



class AdminScheduledProgramController extends \BaseController {

    /**
     * Display a listing of scheduled_programs
     *
     * @return Response
     */
    public function index()
    {
        $programs = ScheduledProgram::all();

        return View::make('admin/scheduled_programs/index', compact('programs'));
    }

我是框架的新手,在路线或控制器中更改路线有意义吗?我怎么做? IE从路由或控制器调用路由?我认为将索引代码从一个复制到另一个是不好的形式。如果我错了,请纠正我。

0 个答案:

没有答案