Custom query in EditRecord
Hi guys,
How to custom the query in EditRecord?
I want to count the relastionship
My code:
8 Replies
If you only want to only show it on the edit page you can use
I mean i want to custom the query of current record to count the relationship. Currently
$record->courses_count
doesn't exists on $record
because I haven't chain ->withCount('courses')
to the querytry:
$record->courses->count()
Hmm, (if it works) it will cause n+1 issue
Well... maybe customize the query:
cool, thanks, I thought so before, but I didn't expect
getEloquentQuery
it work in EditRecord
too.If you right click my solution and go to apps you can mark it as resolved. @ngoquocdat