Get dynamic menu data not working in production Laravel Vue [SOLVED]

Viewed 52

I have a problem after deploy my Laravel, VueJS, InertiaJS website to hosting. The problem is navigation menu is not showing. My menu view code:

<li :class="{ 'current' : $page.props.route === 'Home'}">
    <Link href="/">Home</Link>
</li>
<li v-for="(item_parent, index) in $page.props.menu" :key="index" :class="item_parent.child === null ? { 'current': $page.url.startsWith(`/page/${ item_parent.link }`) }:`dropdown `">
    <Link :href="item_parent.static_page === 1 ? `/page/${ item_parent.link }`: `${ item_parent.link }`" v-if="item_parent.static_page === 0">{{ item_parent.menu_name }}</Link>
    <Link :href="item_parent.child === null ? `/page/${ item_parent.link }`:`#`" v-if="item_parent.static_page === 1">{{ item_parent.menu_name }}</Link>
    <ul>
        <li v-for="(item_child, index) in item_parent.child" :key="index">
            <Link :href="item_child.static_page === 1 ? `/page/${ item_child.link }` : `/${ item_child.link }`">
            {{ item_child.menu_name }}</Link>
        </li>
    </ul>
</li>
<li :class="{ 'current': $page.url.startsWith('/download') }">
    <Link href="/download">Download</Link>
</li>

My Controller get menu data from database:

$parent = Menu::where('active', 1)->where('parent_id', 0)->orderBy('order', 'ASC')->get();

foreach ($parent as $key_parent => $item_parent){
            $this->menu[$key_parent] = array ("parent_id" => $item_parent->parent_id, "menu_name" => $item_parent->menu_name, "link" => $item_parent->link, "static_page" => $item_parent->static_page);
            $this->menu[$key_parent]['child'] = null;
            $child = Menu::where('active', 1)->where('parent_id', $item_parent->id)->orderBy('order', 'ASC')->get();
            if(!$child->isEmpty()){
                foreach ($child as $key_child => $item_child){
                    $this->menu[$key_parent]['child'][$key_child] = array ("parent_id" => $item_child->parent_id, "menu_name" => $item_child->menu_name, "link" => $item_child->link, "static_page" => $item_child->static_page);
                }
            }
        }

return Inertia::render('Frontend/Home', [
            'menu' => $this->menu,
        ]);

And my menu table database structure is like this And my menu table database structure is like this

I confused its work in local development mode, and didnt work in hosting production mode. I also try to change app_debug: true to show error message, but its nothing.

Local: enter image description here

After Deploy: enter image description here enter image description here

dump menu data:

enter image description here

1 Answers

SOLVED

I dont know why, the if condition should be === '1' not only === 1

Related