SQLSTATE [42S22]:找不到列:1054未知列material_tags.material_uuid

I have searched for people who encountered this error but I still can't find the solution.

I have been getting the error:

"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'material_tags.material_uuid' in 'field list' (SQL: select tags.*, material_tags.material_uuid as pivot_material_uuid, material_tags.tag_uuid as pivot_tag_uuid from tags inner join material_tags on tags.uuid = material_tags.tag_uuid where material_tags.material_uuid in (05a36470-d0a0-11e7-91b4-ff3d7d9f961a) and tags.deleted_at is null)"

in which if I have to view Material 05a36470-d0a0-11e7-91b4-ff3d7d9f961a it should look like this enter image description here

When I try to run this code located on the controller:

    public function show(Request $request, $id)
{
    $material   = Material::with('tags')->where(
        'uuid',
        $id
    )->first();

where my Material Model has this:

    public function tags()
{
    return $this->belongsToMany('App\Models\Tag', 'material_tags');

}

So I have a Tags table where all the tags are stored, and a Materials table that has all the materials stored. and I have the Material_tags table to see what Materials have tags.

my create_materials_table at migration

    public function up()
{
    Schema::connection('materials')->create('materials', function (Blueprint $table) {
        $table->uuid('uuid')
            ->primary();
        $table->string('title');
        $table->integer('viewing_time')
            ->default(15)
            ->comment('In seconds');
        $table->text('description')
            ->nullable();
        $table->uuid('organization_id')
            ->nullable();

        $table->timestamps();
        $table->softDeletes();
    });
}

my create_tags_table migration

    public function up()
{
    Schema::connection('materials')->create('tags', function (Blueprint $table) {
        $table->uuid('uuid')
            ->primary();
        $table->string('name')
            ->unique();

        $table->timestamps();
        $table->softDeletes();
    });
}

and my create_material_tags_table migration

public function up()
{
    Schema::connection('materials')->create('material_tags', function (Blueprint $table) {
        $table->uuid('uuid')
            ->primary();
        $table->uuid('material_id');
        $table->uuid('tag_id');

        $table->timestamps();

        $table->foreign('material_id')
            ->references('uuid')
            ->on('materials')
            ->onDelete('cascade');
        $table->foreign('tag_id')
            ->references('uuid')
            ->on('tags')
            ->onDelete('cascade');
    });
}

You have to specify the custom foreign keys:

public function tags()
{
    return $this->belongsToMany('App\Models\Tag', 'material_tags', 'material_id', 'tag_id');
}