I have a main controller CmsController, which is extended to default Laravel controller:
use AppHttpControllersController; class CmsController extends Controller { protected $web = null; public function __construct(Request $request) { $this->web = Web::domain($request->domain)->first(); } }
Now, in this controller I want to call $this->web
use AppHttpControllersWebPageController; class PageController extends CmsController { public function getPage(Request $request) { dd($this->web); // returns always null } }
The data that should be returned is 100% correct, request parameters are also there.
Can someone give me a idea, what I did wrong here?
Advertisement
Answer
I think you need to execute parent constructor:
class PageController extends CmsController { public function __construct() { parent::__construct(); .... } }