8000 [BUG] Accessor method for parent_id on model App\Modules\ProductCatalog\Models\Category does not exist · Issue #55 · fumeapp/modeltyper · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
[BUG] Accessor method for parent_id on model App\Modules\ProductCatalog\Models\Category does not exist #55
Open
@fbarrento

Description

@fbarrento

What happened?

When running vendor/bin/sail artisan model:typer --plurals --api-resources modeltyper return this error:

 Exception 

  Accessor method for parent_id on model App\Modules\ProductCatalog\Models\Category does not exist

  at vendor/fumeapp/modeltyper/src/Actions/DetermineAccessorType.php:38
     34▕             return $reflectionModel->getMethod($method);
     35▕         } catch (Exception $e) {
     36▕         }
     37▕ 
  ➜  38▕         throw new Exception('Accessor method for ' . $mutator . ' on model ' . $reflectionModel->getName() . ' does not exist');
     39▕     }
     40▕ }
     41▕ 

      +21 vendor frames 

  22  artisan:35
      Illuminate\Foundation\Console\Kernel::handle()

I'm using NestedSet Package to manage the categories.

And applying the trait on the categories model.

<?php

namespace App\Modules\ProductCatalog\Models;

use Kalnoy\Nestedset\NodeTrait;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

class Category extends Model
{
    use HasFactory;
    use NodeTrait;

    public $level;

    public $fillable = [
        'name',
        'slug',
        'parent_id',
        'description'
    ];

    public function products(): HasMany
    {
        return $this->hasMany(Product::class);
    }

}

Environment:
laravel: 10
database: postgres

Expected Behavior

The expected behavior is the output of TypeScript interfaces declarations on the console.

Steps To Reproduce

  1. run vendor/bin/sail artisan model:typer --plurals --api-resources
  2. View error

Metadata

Metadata

Assignees

No one assigned

    Labels

    StalebugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0