0
我嘗試了幾乎所有的東西,但我無法獲得以下內容來運行。無法通過構造函數設置佈局
<?php
class BaseController extends Controller {
// Define frontpage layout manager
protected $layout = '';
public function __construct() {
parent::__construct();
$theme = Theme::where('enabled', '=', true)->first();
// HERE !! : This never changes the value of $layout class var
$this->layout = View::make('themes.front.' . $theme->folder . '.master');
// I also tried without View::make(..)
// I also checked that $theme returns something and it does return a theme
}
/**
* Setup the layout used by the controller.
*
* @return void
*/
protected function setupLayout()
{
if (! is_null($this->layout))
{
$this->layout = View::make($this->layout);
}
}
}
我根本無法在我的構造函數中更改$ layout的值。我需要這個讓用戶在佈局之間切換。
有沒有錯誤?它應該沒有'View :: make'。只有'$ this-> layout ='themes.front。' 。 $ theme->文件夾。 '的.master';' –