PHP code example of erag / laravel-setup-layout

1. Go to this page and download the library: Download erag/laravel-setup-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/ */

    

erag / laravel-setup-layout example snippets


return [
    // ...
    LaravelSetupLayoutServiceProvider::class
];

'providers' => [
    // ...
    LaravelSetupLayout\LaravelSetupLayoutServiceProvider::class,
];

Route::get('/', [App\Http\Controllers\HomeController::class, 'index']);

Route::get('/dashboard', [App\Http\Controllers\Dashboard\HomeController::class, 'dashboard']);

// HomeController.php
namespace App\Http\Controllers;

class HomeController extends Controller
{
    public function index()
    {
        addWebAsset(['home']);
        return view('home');
    }
}

// Dashboard/HomeController.php
namespace App\Http\Controllers\Dashboard;

class HomeController extends Controller
{
    public function dashboard()
    {
        addVendors(['demo']);
        return view('dashboard.home');
    }
}

// HomeController.php
public function index()
{
    addWebAsset(['home', 'jq']);
    $data['title'] = 'Home Page';
    return view('home', $data);
}
bash
php artisan vendor:publish --tag=LaravelSetupLayout --force
bash
php artisan make:controller HomeController
bash
php artisan make:controller Dashboard/HomeController
bash
php artisan make:view dashboard.home