Laravel-ide-helper: could not analyze model extended from pivot

Created on 16 Aug 2015  路  9Comments  路  Source: barryvdh/laravel-ide-helper

i have a pivot table who have relationship to other table.
after run
php artisan ide-helper:models
says could not analyze the class how extended from pivot

stale

Most helpful comment

Now that I read this. Isn't it the problem that there's a missing ! in front of the second check?

All 9 comments

Can you paste your relevant code?

Same problem, +1

@barryvdh Is this issue active?

I have the same problem +1

@barryvdh I do not have any suggestions as how to fix this.

What I have seen is that the subclass isn't registered correctly (I think). By changing the test a little, I've seen this:

Changed (src/Console/ModelsCommand.php:184) :

if (!$reflectionClass->isSubclassOf('Illuminate\Database\Eloquent\Model')
        || $reflectionClass->isSubclassOf('Illuminate\Database\Eloquent\Relations\Pivot')) {

    if ($this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
        $this->comment("Model '$name' is no valid Model or Pivot: " . print_r($reflectionClass->getParentClass(), true));
    }

    continue;
}

Relevant output:

Model 'App\Models\Personal\Consumation\Scholarship' is no valid Model or Pivot: ReflectionClass Object
(
    [name] => Illuminate\Database\Eloquent\Relations\Pivot
)

Now that I read this. Isn't it the problem that there's a missing ! in front of the second check?

Looks like it indeed.

The same problem.

    /**
     * @param Pivot $pivotModel
     */
    public function update(Pivot $pivotModel) {
        $pivots = $pivotModel->where()->get();
    }

IDE warning: Method 'where' not found in \Illuminate\Database\Eloquent\Relations\Pivot

The fast solution for _ide_helper.php

replace:

class Eloquent extends \Illuminate\Database\Eloquent\Model {

to:

class Eloquent extends \Illuminate\Database\Eloquent\Relations\Pivot {

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If this issue is still present on the latest version of this library on supported Laravel versions, please let us know by replying to this issue so we can investigate further.
Thank you for your contribution! Apologies for any delayed response on our side.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

half-evil picture half-evil  路  3Comments

celorodovalho picture celorodovalho  路  4Comments

anik786 picture anik786  路  3Comments

GitzJoey picture GitzJoey  路  4Comments

quantumwebco picture quantumwebco  路  4Comments