PHP code example of desmart / laravel-layout
1. Go to this page and download the library: Download desmart/laravel-layout library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
desmart / laravel-layout example snippets
class SampleController extends \DeSmart\Layout\Controller {
protected $layout = 'layouts.default';
protected $structure = array(
'main' => array(
'FancyBanner@show',
'TopStories@show',
),
'right' => array(
'Menu@showTopProducts',
),
);
public function showProducts() {
$this->structure['main'] = array(
'Products@showAll',
);
return $this->execute();
}
public function showOne() {
$this->changeLayout('layouts.product');
$this->structure['main'] = array(
'Products@showOne',
);
return $this->execute();
}
}
Route::get('/', 'SampleController@execute');
Route::get('/products', 'SampleController@showProducts');
Route::get('/products/{product_id}', 'SampleController@showOne');
<header>{{ Layout::dispatch('HomeController@head') }}</header>
class FancyController {
public function test($name, $title = 'sir. ') {}
}
<header> {{ Layout::dispatch('FancyController@test', array('name' => 'Hans')) }} </header>