Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Count cache support nullable #118

Merged

Conversation

fmarquesto
Copy link
Contributor

When we use CountedBy on a nullable field and we set this to null:

...
$table->integer('user_id')->nullable();
...

$post->userId = null;

We receive an unexpected error:
TypeError : Eloquence\Behaviours\CacheConfig::relatedModel(): Return value must be of type Illuminate\Database\Eloquent\Model, null returned

With this PR I've added a validation to avoid retrieving the model on the update method if the foreignKey value is null.

@kirkbushell kirkbushell merged commit d4734d7 into kirkbushell:master May 16, 2024
4 checks passed
@fmarquesto fmarquesto deleted the count-cache-support-nullable branch May 16, 2024 01:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants