laravel-admin
laravel-admin copied to clipboard
Fix related column name in the fill method
Hello.
I found problem with hasOne relation with snakeCased method.
For example, when I have class like this:
class CartItem {
public function productVariant() {
return $this->belongsTo(ProductVariant::class);
}
}
And grid like this
$cartItemsGrid->column('productVariant', 'Product Variant')->display(function ($row) {
return $row;
});
I have an empty row because the loaded field has the name product_variant
but column name like relation method - productVariant.
When I used product_variant
for relation, related data didn't load, because the relation method name does not matched:
$cartItemsGrid->column('product_variant', 'Product Variant')->display(function ($row) {
return $row;
});
My solution in this PR.