Made an edit to indicate that I checked the query via Clockwork and it's exactly correct. For some reason, Filament panel builder just isn't showing the count.
Relationship not working on Filament table
Trying to add some Filament admin panels and I'm having trouble getting a relationship count to work.
I have an IllustratorResource.php that I created with "php artisan make:filament-resource Illustrator".
I have a simple table in there generated with:
->columns([
Tables\Columns\TextColumn::make('id'),
Tables\Columns\TextColumn::make('name')
->searchable(),
Tables\Columns\TextColumn::make('illustratorsToBook_count')
->counts('illustratorsToBook'),
that contains a relationship to my illustrators_to_books table (essentially that column should show me how many books each illustrator has illustrated in that column).
ID and Name work fine, but the 'Illustrators to book count' column is blank (no errors, just no values in that column) even though there are definitely records and the relationship exists in the Illustrator model:
// Relationship to IllustratorsToBooks
public function illustratorsToBook()
{
return $this->hasMany(IllustratorsToBook::class);
}
I checked the actual query via Clockwork and there is nothing wrong with it. Copying the query and pasting it into phpmyadmin results in a column called "illustrators_to_book_count" with all the correct numbers.
Any ideas?
Please or to participate in this conversation.