Closed abbasmashaddy72 closed 4 months ago
Refer to the Relation example.
First, you have to make a method called getOptionsProperty()
where it returns the Options::all()
. Then in the column definition, write Column::name('options.id:count')
. Complete example:
public function column()
{
return [
Column::name('options.id:count')->label('Option count'),
];
}
public function getOptionsProperty()
{
return Option::all();
}
I'm not sure if counting a collection needs the magic property, I'm asking this as well @thyseus.
Okay
I am currently having the same issue. I tried the @NikarashiHatsu approach, which is similar to what was suggested on the repository readme file, but I kept getting errors. @abbasmashaddy72 were you able to find a workaround?
What went wrong? I haven't used this package long enough.
Do you have some code to reproduce the issue?
@dotmarn
I was not able to find any work around, I simply removed the without from my query as it was not so important at the time of delivery of the Project.
Current Query Builder:
public function builder() { return Question::with('topic'); }
Issue Query Builder:
public function builder() { return Question::with('topic')->withCount(['options']); }
And Then I was Not Able to get the Count of Options added for the Particular Question
You can have look at my git repo Quiz Repo Link
You can find the same Current Query in app/Http/Livewire/Tables/Admin/QuestionTable.php
And change the query with issue query builder and You can Notice the Issue
@NikarashiHatsu
@dotmarn
I was not able to find any work around, I simply removed the without from my query as it was not so important at the time of delivery of the Project.
I had to leave it too after spending quite some time trying to figure out the issue.
I am using query builder to return the result added all the
Question::with('topic')->withCount(['options']);
When I am using the same query with get in Controller, I am getting the options_count result, but I am unable to get the same with query builder
I am getting the column not found error.
Column not found: 1054 Unknown column 'questions.options_count' in 'field list'
Please Help me out