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
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.
Most helpful comment
Now that I read this. Isn't it the problem that there's a missing
!in front of the second check?