Jonjie
2 months ago
215
1
Laravel

How to select child column in laravel eloquent using select

Posted 2 months ago by Jonjie

I'm trying to select a column from child table using eloquent and select method but it return a column not found error. Please see my code below.

My Code

return Restaurant::with(['merchant'])->select('name', 'address', 'merchant.email')->findOrFail($id);

Error

Column not found: 1054 Unknown column 'merchant.email' in 'field list'

Please sign in or create an account to participate in this conversation.