Skip to content

Relations not shown in artisan command model:show  #206

Closed
@cpuch

Description

@cpuch

Hello,

I have a Client model with a HasManyDeep relation as follow

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Staudenmeir\EloquentHasManyDeep\HasManyDeep;
use App\Models\ListItem;
use App\Models\RoyaltiesArtist;
use App\Models\RoyaltiesContrat;

class Client extends Model
{
    use HasFactory;
    use \Staudenmeir\EloquentHasManyDeep\HasRelationships;

    [...]

    public function artistContracts(): HasManyDeep
    {
        return $this->hasManyDeep(
            RoyaltiesContrat::class,
            [RoyaltiesArtist::class, ListItem::class], // Intermediate models, beginning at the far parent (Client).
            [
                'id_client',          // Foreign key on the royalties_artist table.
                'id_item',            // Foreign key on the list_item table.
                'id_list_info_artist' // Foreign key on the royalties_contrat table.
            ],
            [
                'id_client', // Local key on the client table.
                'id',        // Local key on the royalties_artist table.
                'id_list',   // Local key on the list_item table.
            ]
        );
    }

    [...]
}

When I use the artisan command the relation is not displayed

 php artisan model:show Client

  App\Models\Client ................................................................................................................................
  Database .............................................................................................................................. soundworks
  Table ..................................................................................................................................... client

  Attributes ........................................................................................................................... type / cast
  id_client increments, unique .............................................................................................. integer unsigned / int

  [...]

  Relations ........................................................................................................................................
  password HasOne .............................................................................................................. App\Models\Password
  artist HasOne ......................................................................................................... App\Models\RoyaltiesArtist
  bands HasMany ........................................................................................................... App\Models\RoyaltiesBand
  bandContracts HasManyThrough ......................................................................................... App\Models\RoyaltiesContrat

  Observers ........................................................................................................................................

It would be nice if the artisan command could return the relationship.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions