Extension Version
1.5.1
PHP Binary
Sail
Operating System
Linux
What happened?
When using withCount or loadCount a {relation}_count attribute is placed on the model, these attributes are "snake case", when the relation on a model is "camel case" the relation needs to be converted to "snake case".
This is what is in my _model_helpers file:
@property-read int|null $testResults_count
It should be this:
@property-read int|null $test_results_count
Mimimal Code Sample
public function testResults(): HasMany
{
return $this->hasMany(TestResult::class);
}
$model->loadCount('testResults');
dump($model->test_results_count); // 1
dump($model->testResults_count); // Illuminate\Database\Eloquent\MissingAttributeException The attribute [testResults_count] either does not exist or was not retrieved for model [App\Models\...].