PHPackages                             italia/design-laravel-theme - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. italia/design-laravel-theme

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

italia/design-laravel-theme
===========================

Easy Bootstrap-Italia integration with Laravel 5

1.3.8(6y ago)16718↓66.7%6[1 issues](https://github.com/italia/design-laravel-theme/issues)[1 PRs](https://github.com/italia/design-laravel-theme/pulls)BSD-3-ClausePHPPHP &gt;=7.1CI failing

Since Apr 1Pushed 1y ago8 watchersCompare

[ Source](https://github.com/italia/design-laravel-theme)[ Packagist](https://packagist.org/packages/italia/design-laravel-theme)[ RSS](/packages/italia-design-laravel-theme/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (2)Versions (22)Used By (0)

Easy Bootstrap-Italia integration with Laravel
==============================================

[](#easy-bootstrap-italia-integration-with-laravel)

[![Join the #design-cms-themes channel](https://camo.githubusercontent.com/4febf2bab893da1c08e290127fe9e8b75d00ca8161b7252ce166457e2387a0d6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f536c61636b2532306368616e6e656c2d25323364657369676e2d2d636d732d2d7468656d65732d626c75652e7376673f6c6f676f3d736c61636b)](https://developersitalia.slack.com/messages/C91K0K085)[![Get invited](https://camo.githubusercontent.com/90f3bb527b0d0731e5ae345ea34a3ab7ef763b78dd16a3208002eeefb9b08c8c/68747470733a2f2f736c61636b2e646576656c6f706572732e6974616c69612e69742f62616467652e737667)](https://slack.developers.italia.it/)[![Design on forum.italia.it](https://camo.githubusercontent.com/27ec905de0ed77d1ca7af268aa7e94fa207a933e4917293b2570f32df6d73460/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f466f72756d2d44657369676e2d626c75652e737667)](https://forum.italia.it/c/design/user-interface) [![Latest Stable Version](https://camo.githubusercontent.com/33092f6eb44ec8a7d5c742980d733223dd76e63183ea377919b9a53eec7e29bf/68747470733a2f2f706f7365722e707567782e6f72672f6974616c69612f64657369676e2d6c61726176656c2d7468656d652f762f737461626c652e706e67)](https://packagist.org/packages/italia/design-laravel-theme)[![Total Downloads](https://camo.githubusercontent.com/db2baeb6443077e5cdcc9fc04fb368fa583c92cbfa751f095c4f9475f9ddd216/68747470733a2f2f706f7365722e707567782e6f72672f6974616c69612f64657369676e2d6c61726176656c2d7468656d652f646f776e6c6f6164732e706e67)](https://packagist.org/packages/italia/design-laravel-theme)

This package provides an easy way to quickly set up [Bootstrap Italia](https://italia.github.io/bootstrap-italia/) with Laravel. It has no requirements and dependencies besides Laravel, so you can start building your website immediately. The package just provides a Blade template that you can extend and advanced menu configuration possibilities.

1. [Installation](#1-installation)
2. [Updating](#2-updating)
3. [Usage](#3-usage)
4. [The `make:bootstrapitalia` artisan command](#4-the-makebootstrapitalia-artisan-command)
5. [Configuration](#5-configuration)
    1. [Menu](#51-menu)

    - [Custom menu filters](#custom-menu-filters)
    - [Menu configuration at runtime](#menu-configuration-at-runtime)
    - [Active menu items](#active-menu-items)
6. [Translations](#6-translations)
7. [Customize views](#7-customize-views)
8. [Issues, Questions and Pull Requests](#8-issues-questions-and-pull-requests)

1. Installation
---------------

[](#1-installation)

1. Require the package using composer:

    ```
    composer require italia/design-laravel-theme

    ```
2. Add the service provider to the `providers` in `config/app.php`:

    > Laravel 5.5 uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider

    ```
    italia\DesignLaravelTheme\ServiceProvider::class,
    ```
3. Publish the public assets:

    ```
    php artisan vendor:publish --provider="italia\DesignLaravelTheme\ServiceProvider" --tag=assets

    ```

2. Updating
-----------

[](#2-updating)

1. To update this package, first update the composer package:

    ```
    composer update italia/design-laravel-theme

    ```
2. Then, publish the public assets with the `--force` flag to overwrite existing files

    ```
    php artisan vendor:publish --provider="italia\DesignLaravelTheme\ServiceProvider" --tag=assets --force

    ```

3. Usage
--------

[](#3-usage)

To use the template, create a blade file and extend the layout with `@extends('bootstrap-italia::page')`. This template yields the following sections:

- `title`: for in the `` tag
- `content`: all of the page's content
- `css`: extra stylesheets (located in ``)
- `js`: extra javascript (just before ``)

All sections are in fact optional. Your blade template could look like the following.

```
{{-- resources/views/test.blade.php --}}

@extends('bootstrap-italia::page')

@section('title', 'Bootstrap Italia')

@section('content')
    Test page.
@stop

@section('css')

@stop

@section('js')
     console.log('Hi!');
@stop
```

Note that in Laravel 5.2 or higher you can also use `@stack` directive for `css` and `javascript`:

```
{{-- resources/views/test.blade.php --}}

@push('css')

@push('js')
```

You now just return this view from your controller, as usual. Check out [Bootstrap Italia](https://italia.github.io/bootstrap-italia/) to find out how to build content for your pages.

4. The `make:bootstrapitalia` artisan command
---------------------------------------------

[](#4-the-makebootstrapitalia-artisan-command)

> Note: only for Laravel 5.2 and higher

This package ships with a `make:bootstrapitalia` command that behaves exactly like `make:auth` (introduced in Laravel 5.2). In the near future it will publish auth views with bootstrap-italia styles.

It will also create custom pagination links views under `vendor/pagination` folder

```
php artisan make:bootstrapitalia

```

This command should be used on fresh applications, just like the `make:auth` command

5. Configuration
----------------

[](#5-configuration)

First, publish the configuration file:

```
php artisan vendor:publish --provider="italia\DesignLaravelTheme\ServiceProvider" --tag=config

```

Now, edit `config/bootstrap-italia.php` to configure the title, theme, menu, URLs etc. All configuration options are explained in the comments. However, I want to shed some light on the `menu` configuration.

### 5.1 Menu

[](#51-menu)

You can configure your menu as follows.

Basically, you have three keys: `slim_header`, `header` and `footer`, which defines how the three sections are configured:

```
'menu' => [
    'slim-header' => [],
    'header' => [],
    'footer' => [],
    'footer-bar' => [],
],
```

`slim_header` and `footer_bar` are configured as

```
'menu' => [
        'slim-header' => [
            [
                'url' => '#',
                'text' => 'Pagina iniziale',
            ],
            [
                'url' => '#',
                'text' => 'Contatti',
                'target' => '_blank',
            ],
        ],
        ...
]
```

```
'menu' => [
        'footer-bar' => [
            [
                'url' => '#',
                'text' => 'Privacy policy',
            ],
            [
                'url' => '#',
                'text' => 'Contatti',
                'target' => '_blank',
            ],
        ],
        ...
]
```

`footer` is configured as

```
'menu' => [
        ...
        'footer' => [
                    [
                        [
                            'text' => 'Amministrazione',
                            'url' => '#',
                            'target' => '_blank',
                        ],
                        [
                            'text' => 'Giunta e consiglio',
                            'url' => '#',
                        ],
                    ],
                    [
                        [
                            'text' => 'Amministrazione',
                            'url' => '#',
                        ],
                        [
                            'text' => 'Giunta e consiglio',
                            'url' => '#',
                        ],
                    ],
                ],
]
```

while `header` is more complex, since each element could be an `string`, a `simple item`, a `dropdown` or a `megamenu`:

- `string` is just a string without links
- a `simple item` is an associative array with the form:

```
[
    'url' => '/home',
    'text' => 'Home',
    'target' => '_blank',
],
```

- a `dropdown` is an item with the `dropdown` key set to an array of `simple items`, `headers`, or `separators` (string '-'):

```
[
    'url' => '/home',
    'text' => 'Dropdown item',
    'dropdown' => [
        'Intestazione',
        [
            'url' => '/home',
            'text' => 'Home',
            'target' => '_blank',
        ],
        '-',
        [
            'url' => '/about',
            'text' => 'About',
        ],
],
```

- a `megamenu` is an item with the `megamenu` key set to bi-dimensional array of `simple items`, `headers`, or `separators` (string '-'):

```
[
    'text' => 'Megamenu item',
    'megamenu' => [
        [
            'Heading 1',
            [
                'url' => '/home',
                'text' => 'Home',
                'target' => '_blank',
            ],
            '-',
            [
                'url' => '/about',
                'text' => 'About',
            ],
        ],
        [
        'Heading 2',
            [
                'url' => '/a',
                'text' => 'Link a',
            ],
            '-',
            [
                'url' => '/b',
                'text' => 'Link b',
            ],
        ],
    ]
],
```

For each of the previous, with a single string, you specify a menu header item to separate the items. With an array, you specify a menu item. `text` and `url` or `route` are required attributes.

Use the `can` option if you want conditionally show the menu item. This integrates with Laravel's `Gate` functionality.

```
[
    [
        'text' => 'Create request',
        'url' => 'request/new',
        'can' => 'create-request'
    ],
]
```

#### Custom Menu Filters

[](#custom-menu-filters)

If you need custom filters, you can easily add your own menu filters to this package. This can be useful when you are using a third-party package for authorization (instead of Laravel's `Gate` functionality).

For example with Laratrust:

```
