invoker-community icon indicating copy to clipboard operation
invoker-community copied to clipboard

can't find method on model that contains underscore

Open lightwalkernet opened this issue 4 years ago • 5 comments


OS: darwin Invoker Version: 2.0.2 Laravel Version: 8.22.1 Local project: true PHP Binary: /usr/local/bin/php Route: /project/index?class=App%5CUser&time=1612386170472&project=local-4Ep3udexmFQ5tkqPLfdxkS

Error:

BadMethodCallException 

  Call to undefined method App\User::curaReports()

  at /Users/aaronkenton/websites/numinous/vendor/laravel/framework/src/Illuminate/Support/Traits/ForwardsCalls.php:50
     46▕      * @throws \BadMethodCallException
     47▕      */
     48▕     protected static function throwBadMethodCallException($method)
     49▕     {
  ➜  50▕         throw new BadMethodCallException(sprintf(
     51▕             'Call to undefined method %s::%s()', static::class, $method
     52▕         ));
     53▕     }
     54▕ }

  • Bad Method Call: Did you mean App\User::cura_reports() ? 

      [2m+7 vendor frames [22m
  8   phar:/Applications/Invoker.app/Contents/Resources/invoker.phar/src/Actions/IndexResourceAction.php:129
      Illuminate\Database\Eloquent\Builder::withCount()

  9   phar:/Applications/Invoker.app/Contents/Resources/invoker.phar/src/Actions/IndexResourceAction.php:51
      _HumbugBoxe923e1c0def2\Invoker\Actions\IndexResourceAction::addWithCount()

In my user model the relationship is set up using this method:

  public function cura_reports()
    {
        return $this->hasMany(\App\Models\Cura\Reports::class);
    }

I am getting similar errors like the one above on other relationships. Is it throwing an error because of the underscore in the method name? I am using underscore because it allows me to seperate similar relationships for different domains in a multi tenancy app.

What would you suggest?

lightwalkernet avatar Feb 03 '21 21:02 lightwalkernet

Yeah, it's a bug because of the snake_case naming of your relation. I currently convert the relations to camelCase, when adding them as counts or eager load them. I'll look into this 👍

mpociot avatar Feb 03 '21 22:02 mpociot

Thanks for looking into it.

lightwalkernet avatar Feb 07 '21 21:02 lightwalkernet

Any news on this bug fix? Or should I change my naming convention?

lightwalkernet avatar Feb 18 '21 20:02 lightwalkernet

Any ETA on this? Wish I'd known this before paying. Pretty big deal breaker.

aaronlord avatar Jul 21 '21 11:07 aaronlord

I would agree. I was very excited about invoker but have not been able to use it since I purchased.

lightwalkernet avatar Jul 21 '21 22:07 lightwalkernet