lepikhinb / laravel-typescript

MIT License
391 stars 46 forks source link

Double Properties in same Generated Model interface #31

Closed AlexisVS closed 12 months ago

AlexisVS commented 1 year ago

Hi there,

I'm encountering an issue with the properties of a generated Model in my project. The Model in question has a relationship with itself, representing a menu with parent and child elements within the same table. The parent property is functioning correctly, but there seems to be another property causing problems.

To help you diagnose the issue, here are the details you need:

<?php

namespace App\Infrastructure\Laravel\Models\AdministrationMenu;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Spatie\MediaLibrary\MediaCollections\Models\Concerns\HasUuid;

/**
 * App\Infrastructure\Laravel\Models\AdministrationMenu\AdministrationMenu
 *
 * @property int $id
 * @property string $uuid
 * @property string $name
 * @property string|null $url
 * @property string|null $icon_name
 * @property string|null $icon_path
 * @property string|null $permission
 * @property string|null $entity_name
 * @property mixed|null $parent_permissions
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @property-read \Illuminate\Database\Eloquent\Collection<int, AdministrationMenu> $children
 * @property-read int|null $children_count
 * @method static \Illuminate\Database\Eloquent\Builder|AdministrationMenu newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|AdministrationMenu newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|AdministrationMenu query()
 * @method static \Illuminate\Database\Eloquent\Builder|AdministrationMenu whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdministrationMenu whereEntityName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdministrationMenu whereIconName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdministrationMenu whereIconPath($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdministrationMenu whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdministrationMenu whereName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdministrationMenu whereParent($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdministrationMenu whereParentId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdministrationMenu whereParentPermissions($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdministrationMenu wherePermission($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdministrationMenu whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdministrationMenu whereUrl($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdministrationMenu whereUuid($value)
 * @mixin \Eloquent
 * @noinspection PhpFullyQualifiedNameUsageInspection
 */
class AdministrationMenu extends Model
{
    use HasFactory, HasUuid;

    public function children(): HasMany
    {
        return $this->hasMany(AdministrationMenu::class, 'parent_id');
    }

    public function parent(): BelongsTo
    {
        return $this->belongsTo(AdministrationMenu::class, 'parent_id');
    }
}
declare namespace App.Infrastructure.Laravel.Models.AdministrationMenu {
    export interface AdministrationMenu {
        id: number;
        uuid: string;
        name: string;
        url: string | null;
        icon_name: string | null;
        icon_path: string | null;
        permission: string | null;
        parent_id: number | null;
        parent: boolean;
        entity_name: string | null;
        parent_permissions: Array<any> | any | null;
        created_at: string | null;
        updated_at: string | null;
        children?: Array<App.Infrastructure.Laravel.Models.AdministrationMenu.AdministrationMenu> | null;
        parent?: App.Infrastructure.Laravel.Models.AdministrationMenu.AdministrationMenu | null;
        children_count?: number | null;
    }

}