Skip to content

pkboom/laravel-inertia-vue-component

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Opinionated Inertia Vue Component Creator

Installation

Install the package via composer:

composer require pkboom/laravel-inertia-vue-component

Usage

Create a new controller, which contains Inertia:render.

// SomeController.php

public function index() {
    return Inertia::render('Some/Index', [
        'foo' => 'foo',
        'bar' => 'bar',
    ]);
}

Run this command.

php artisan make:inertia-vue-component <Controller Name>
// e.g. php artisan make:inertia-vue-component SomeController

js/Pages/Some/Index.vue is created with props

export default {
    props: {
        foo: String,
        bar: String,
    }
    ...
}

To add a prop to an existing component, first add a new key => value to Inertia::render.

// SomeController.php

public function index() {
    return Inertia::render('Some/Index', [
        'foo' => 'foo',
        'bar' => 'bar',
        'new' => 'new',
    ]);
}

Run this command.

php artisan make:inertia-vue-component SomeController

A new prop is created in js/Pages/Some/Index.vue.

export default {
    props: {
        new: String,
        foo: String,
        bar: String,
    }
    ...
}

Publish to edit stub.

php artisan vendor:publish --provider="Pkboom\InertiaVueComponent\InertiaVueComponentServiceProvider"

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages