-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
error when using composite key package #838
Comments
@MartinP7r (CC @barryvdh) Quick fix for this issue (requires <?php
namespace App\Console\Commands\IdeHelper;
use Barryvdh\LaravelIdeHelper\Console\ModelsCommand as BaseModelsCommand;
use Illuminate\Support\Arr;
use Illuminate\Database\Eloquent\Relations\Relation;
class ModelsCommand extends BaseModelsCommand
{
/**
* @param string $relation
* @param Relation $relationObj
* @return bool
*/
protected function isRelationNullable(string $relation, Relation $relationObj): bool
{
$reflectionObj = new \ReflectionObject($relationObj);
if (in_array($relation, ['hasOne', 'hasOneThrough', 'morphOne'], true) || !$reflectionObj->hasProperty('foreignKey')) {
return parent::isRelationNullable($relation, $relationObj);
}
$fkProp = $reflectionObj->getProperty('foreignKey');
$fkProp->setAccessible(true);
return (bool)Arr::first(
(array)$fkProp->getValue($relationObj),
fn (string $value) => isset($this->nullableColumns[$value])
);
}
} |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
error stil exist in "barryvdh/laravel-ide-helper": "^2.10" and "awobaz/compoships": "^2.1", Trace:
Model:
|
I'm facing the same problem in version 2.10 and solved by checking each compoships array key element: ...\web\vendor\barryvdh\laravel-ide-helper\src\Console\ModelsCommand.php
|
#706 seems related
I'm using
awobaz/compoships
(https://github.com/topclaudy/compoships) for a relationship that uses composite keys in one of my models, which seems to break the generation script for models as it throws the following error:the breaking composite key relationship looks like this:
I realize that you can't account for 3rd party packages, but would there be a workaround way to at least exclude the relationship from scanning?
The text was updated successfully, but these errors were encountered: