'Laravel Livewire Tables - Filter not working

Noob question (sorry in advance if it's dumb) but I'm honestly trying to understand it all.

I'm new to Laravel and still finding my way around. I'm using Laravel Livewire Tables and I'm trying to apply a filter on my table but it's not working as expected. I'm sure this is very obvious to someone, but to me... it's not.

According to the docs, I can make a filter by following these instructions, however, it's not working as expected. My code is:

public function query(): Builder
    {
        return User::query()
        // Neither are working correctly.
        //->when($this->getFilter('active'), fn ($query, $type) => $query->where('type', $type));
        ->when($this->getFilter('ismedic'), fn ($query, $ismedic) => $query->where('ismedic', true));
    }


    public function filters(): array
    {
        return [

            'ismedic' => Filter::make('Is Medic')
                ->select([
                    '' => 'Any',
                    'true' => 'Yes',
                    'null' => 'No',
                ]),  
        ];
    }

I've tried changing values, adding 1s or 0s and changing true to $ismedic but I'm just guessing at this point and even if I did manage to fix it, I wouldn't know what I'm doing wrong.

Background info: I have a 'users' table with a column of ismedic which is a boolean of either 1 or 0. The table shows the filter and I get the Yes or No option to choose from. When selecting Yes, the table does seem to filter correctly. When selecting No, the table doesn't seem to do anything. When selecting Any, the filter is removed and I can see all records.

If anyone can help, could you please describe anything as if you're talking to a super-noob please? Thank you!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source