Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vuetify with Laravel

I am working on a new Laravel Project, where I would like to use Vuetify.

I managed to configure and create the default layout. This is my master,blade.php layout file:

<!DOCTYPE html>
<html lang="{{ config('app.locale') }}">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- CSRF Token -->
    <meta name="csrf-token" content="{{ csrf_token() }}">

    <title>{{ config('app.name', 'Laravel') }}</title>

    <link href="{{ asset('css/app.css') }}" rel="stylesheet">
    <link href="{{ asset('css/vuetify.min.css') }}" rel="stylesheet">

    <script>
        window.Laravel = {!! json_encode([
            'csrfToken' => csrf_token(),
        ]) !!};
    </script>
    </head>
    <body>
    <v-app id="app" top-toolbar footer v-cloak>
        <v-navigation-drawer persistent light :mini-variant.sync="mini" v-model="drawer">
            <v-list class="pa-0">
                <v-list-item>
                    <v-list-tile avatar tag="div">
                        <v-list-tile-avatar>
                            <img src="http://ma.twyn.com/bilder/tba.jpg" />
                        </v-list-tile-avatar>
                        <v-list-tile-content>
                            <v-list-tile-title>Tamás Barta</v-list-tile-title>
                        </v-list-tile-content>
                        <v-list-tile-action>
                            <v-btn icon @click.native.stop="mini = !mini">
                                <v-icon>chevron_left</v-icon>
                            </v-btn>
                        </v-list-tile-action>
                    </v-list-tile>
                </v-list-item>
            </v-list>
            <v-list class="pt-0" dense>
            <v-divider></v-divider>
            <v-list-item v-for="item in items" :key="item">
                <v-list-tile>
                    <v-list-tile-action>
                        <v-icon>@{{ item.icon }}</v-icon>
                    </v-list-tile-action>
                    <v-list-tile-content>
                        <v-list-tile-title><a href="/partners">@{{ item.title }}</a></v-list-tile-title>
                    </v-list-tile-content>
                </v-list-tile>
            </v-list-item>
        </v-list>
        </v-navigation-drawer>
        <v-toolbar fixed class="primary darken-4" light>
            <v-toolbar-side-icon light @click.native.stop="drawer = !drawer"></v-toolbar-side-icon>
            <v-toolbar-title>PRM</v-toolbar-title>
        </v-toolbar>
        <main>
            <v-container fluid>
                @yield('content')
            <!--v-router-->
            </v-container>
        </main>
    </v-app>

    <script src="{{ asset('js/app.js') }}"></script>
    <script src="{{ asset('js/prm.js') }}"></script>
    </body>
    </html>

My question is how do i use this components correctly?

Do I have to make component files, for each component im using?

Do I only have one Vue instance for the main id #app?

Sadly i could not find any examples or guidlines beside the vuetify page. I would be awesome if some one with experience could give me a push in the right direction

like image 955
therabbityouknow Avatar asked Oct 29 '22 06:10

therabbityouknow


1 Answers

There are multiple ways you can go about using Vue (w/Vuetify) in Laravel. You can use it inside blade templates, as long as your javascript file is mounting to the DOM, any components/Vue used within that binding will work just fine.

You can also use the Laravel/Vue boilerplate that can be setup, https://laravel.com/docs/5.4/frontend , and create all of your markup with Vue template files.

like image 129
John Leider Avatar answered Nov 10 '22 15:11

John Leider