thedevdojo / voyager

Voyager - The Missing Laravel Admin
https://voyager.devdojo.com
MIT License
11.77k stars 2.67k forks source link

Why relation column doesn't show in Menu's browse page? #5697

Open lamualfa opened 1 year ago

lamualfa commented 1 year ago

Note: This issue only occurs for Voyager's tables.

Versions

Laravel version

9.39.0

PHP version

8.1.7

Voyager version

1.6

Database

MYSQL 8.0

Description

Locale column doesn't show any data on the browse page

image

Even though the Locale column appears on the edit page

image

Steps to reproduce

1. Create Locale migration

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('locales', function (Blueprint $table) {
            $table->id();
            $table->string('code');
            $table->string('short_name');
            $table->string('name');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('locales');
    }
};

2. Create a migration to update the menu table

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('menus', function (Blueprint $table) {
            $table->foreignId('locale_id')->nullable()->constrained()->nullOnDelete();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('menus', function (Blueprint $table) {
            $table->dropForeign('locale_id');
        });
    }
};

3. Setup Locale's bread

4. Setup Relation field on Menu's bread

5. Add some locales data

6. Edit a menu data and connect the locale created before

Expected behavior

Menu's browse page shows the relation column properly.

Additional Context

Locale roles

image

Relation details on Menu's bread page

image

image

Menu table

image

Locale table

image

syed-reza98 commented 1 year ago

Check the file path for Locale Model

204759249-aa532d02-3fa8-4041-80b3-9145f64bdc29__01

lamualfa commented 1 year ago

@syed-reza98 It exist. I created it before the bread creation.