Php 拉威尔5号布局图
我想知道Laravel5中的总体布局是什么样的,如果它在L4中,那么我写了一些代码。我一直在用,但我想要我自己的东西。如果有人能给我一些想法,那将是很有用的 Controller.php: routes.php:Php 拉威尔5号布局图,php,layout,laravel-4,laravel-5,Php,Layout,Laravel 4,Laravel 5,我想知道Laravel5中的总体布局是什么样的,如果它在L4中,那么我写了一些代码。我一直在用,但我想要我自己的东西。如果有人能给我一些想法,那将是很有用的 Controller.php: routes.php: <?php abstract class Controller extends BaseController { use DispatchesCommands, ValidatesRequests; protected $layout = null;
<?php
abstract class Controller extends BaseController
{
use DispatchesCommands, ValidatesRequests;
protected $layout = null;
function __construct()
{
$this->setLayout();
}
protected function setPageContent($content)
{
if (is_null($this->layout)) {
throw new Exception('layout was not set');
}
return view($this->layout, ['content' => view($content)]);
}
public function setLayout()
{
$lay = DB::table('layout')->where('selected', 1)->first();//i select the layout from a database
return $this->layout = $lay->name . ".layouts." . $lay->name; //create a file with the database name
}
protected function setView($vista)
{
$view = DB::table('layout')->where('selected', 1)->first();
return $view->name . '/' . $vista;
}
}
public function getIndex($page = null)
{
if ($page == null) {
return $this->setPageContent($this->setView('index'));
} else {
return $this->setPageContent($this->setView($page));
}
}
Route::controller('/{page?}/{param?}', 'MainController');