在Laravel 4.2中Redirect :: to()之后的空白页面

时间:2015-05-10 20:24:54

标签: laravel laravel-4 laravel-routing

我在Laravel 4.2中Redirect::to()之后阅读了很多关于空白页的内容。这是我的控制器功能:

public function profile($salon_id){
        $salon_profile = $this->mSalon->getSalon($salon_id);

        if(Session::get("user_type.dist_content_filter") && Session::get("user.distributor_id")!=$salon_profile["distributor_id"]){
            return Redirect::to('error/401');
        }

        $lstDistributors = $this->mDistributor->getDistributors(array());
        $lstCountries = (new Countries)->getCountries();

        View::share('lstCountries', $lstCountries);
        View::share('lstDistributors', $lstDistributors);
        View::share('salon_profile', $salon_profile);

        if(Session::get('success')){
            View::share('box_message', array("type"=>"Success","message"=>"Distributor saved successfully"));
        }

        self::setCSS("header",Config::get('cdn.css_path') . "datepicker.css");      
        self::setJS("footer",Config::get('cdn.js_path') . "jquery.validate.min.js");
        self::setJS("footer",Config::get('cdn.js_path') . "date-time/bootstrap-datepicker.min.js");
        self::setJS("footer",Config::get('cdn.js_path') . "jquery.maskedinput.min.js");

        echo View::make('common/header');
        echo View::make('salon/profile');
        echo View::make('common/footer');
    }

我的路线:

Route::group(array('prefix' => 'error'), function(){
    Route::get('/{error_number}', 'ErrorController@showError');
}); 

有人可以帮我解释为什么我会收到空​​白页吗?

谢谢,

古斯塔沃

1 个答案:

答案 0 :(得分:0)

我发现了问题,这是我的错误。此配置文件的路径不会直接调用配置文件方法:

Route::get('/{action}/{object_id}', 'SalonController@action');

所以,在我的控制器中我有(错误的解决方案):

public function action($action, $object_id = null){
    if(method_exists($this,$action)){
        $this->$action($object_id);
    }else{
        return App::missing();
    }}

正确的解决方案:

public function action($action, $object_id = null){
if(method_exists($this,$action)){
    return $this->$action($object_id);
}else{
    return App::missing();
}}

我需要在行中加入回复:$this->$action.....

由于