Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use a Laravel Nova Component in a Custom Nova Tool

I'd like to use the same loader as Laravel Nova uses when it's components are loading. I can't get it to compile. It never recognizes where to load the LoadingCard component from. Any help would be appreciated.

<template>
    <div>
        <heading class="mb-6">Tax Calculator</heading>

        <loading-card :loading="loading" class="card relative overflow-hidden w-1/3">
            <div v-if="countries.length">
                <!--Make form-->
            </div>
        </loading-card>
    </div>
</template>

<script>
    import LoadingCard from 'laravel-nova'
    export default {
        mounted() {
            let vue = this;
            Nova.request().get('/nova-vendor/tax-calculator/mount')
                .then(response => {
                    vue.countries = response.data.countries;
                    vue.states = response.data.states;
                });
        },
    }
</script>

<style>
    /* Scoped Styles */
</style>
like image 825
Cam Avatar asked Mar 05 '23 06:03

Cam


1 Answers

Figured it out. Apparently all the Nova built-in components are available globally. Didn't realize this. All I needed to do to get it to compile was remove the import statement. I modified the code as follows:

<template>
    <div>
        <heading class="mb-6">Tax Calculator</heading>

        <loading-card :loading="loading" class="card relative overflow-hidden w-1/3">
            <!--Make form-->
        </loading-card>
    </div>
</template>

<script>
    export default {
        mounted() {
            let vue = this;
            Nova.request().get('/nova-vendor/tax-calculator/mount')
                .then(response => {
                    vue.countries = response.data.countries;
                    vue.states = response.data.states;
                });
        },
    }
</script>

<style>
    /* Scoped Styles */
</style>
like image 83
Cam Avatar answered Mar 26 '23 14:03

Cam