Skip to content

Instantly share code, notes, and snippets.

@darrylmorley
Last active September 26, 2022 14:47
Show Gist options
  • Save darrylmorley/c65e47626447edf7c99e2fa9f24c6b7e to your computer and use it in GitHub Desktop.
Save darrylmorley/c65e47626447edf7c99e2fa9f24c6b7e to your computer and use it in GitHub Desktop.
Laravel

Set a default Layout - Inertia / Vue

createInertiaApp({
  resolve: (name) => {
    let page = resolvePageComponent(
			`./Pages/${name}.vue`,
			import.meta.glob('./Pages/**/*.vue')
    );
    page.then((module) => {
      	     module.default.layout ??= Layout;
    });
    return page;
  },
  setup({ el, App, props, plugin }) {
    createApp({ render: () => h(App, props) })
      .use(plugin)
      .component("Link", Link)
      .mount(el)
  },
});

Laravel Inertia Demo App - Laracasts

Quickstart for Laravel inertia apps with Vue:

  1. composer require laravel/breeze --dev
  2. php artisan breeze:install vue

This does the following:

  1. Generates the app.blade.php and its contents.
  2. Middleware, which generates the HandleInertiaRequests middleware.
  3. Install dependencies, client-side adapters, and progress indicators.
  4. Initialize app, which updates our app.js file under the resources/js with the proper config.
  5. Generates tailwind.config.js
  6. Generates webpack.mix.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment