获取__construct()必须是App \ Models \ Page的实例,没有给定消息

时间:2016-01-19 20:41:34

标签: php laravel-5

当试图访问另一个控制器中的某个函数时,我收到一条__construct() must be an instance of App\Models\Page, none given错误消息,我想知道如何解决这个问题......

从中调用函数的控制器:

use App\Http\Controllers\Frontend\PagesController;
...
class ModulesController extends Controller {

    public function filter(Request $request) {
        $items = $this->loadFilteredItems($request->module_id, $request->filters);
        $page = new PagesController();
        $header = $page->loadElements($request->id, false);
        return View::make(
            'base.frontend.' . config('folder') . '.includes.filter', 
            compact('items', 'header'));
        }
    }
}

存储功能的控制器:

class PagesController extends Controller {

    private $page;

    public function __construct(Page $page) {
        $this->page = $page;
    }

    private function loadElements($id) {
        return 'something';
    }

}

1 个答案:

答案 0 :(得分:0)

将控制器改编为:

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.8683
                                                        longitude:151.2086
                                                             zoom:6];
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
mapView_.mapType = kGMSTypeSatellite;

它现在正在工作