I'm having a problem with casting the correct types for return values I'm getting the following errors from the WithBulkActions trait. I've added the trait in a comment to this post.
Call to an undefined method Illuminate\Contracts\Pagination\LengthAwarePaginator::pluck().
Call to an undefined method Illuminate\Database\Query\Builder::whereKey().
<?php
declare(strict_types=1);
namespace App\Http\Livewire\Events;
use App\Http\Livewire\BaseComponent;
use App\Http\Livewire\Datatable\WithBulkActions;
use App\Http\Livewire\Datatable\WithSorting;
use App\Models\Event;
use Illuminate\Contracts\Database\Query\Builder;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Livewire\Attributes\Computed;
/**
* @property LengthAwarePaginator $rows
* @property Builder $rowsQuery
*/
class EventsList extends BaseComponent
{
use WithBulkActions;
use WithSorting;
#[Computed]
public function rowsQuery(): EloquentBuilder
{
$query = Event::query()
->when($this->filters['search'], fn (EloquentBuilder $query, string $search) => $query->where('name', 'like', '%'.$search.'%'))
->oldest('name');
return $this->applySorting($query);
}
/**
* Undocumented function.
*/
#[Computed]
public function rows(): LengthAwarePaginator
{
return $this->applyPagination($this->rowsQuery);
}
...
}