Widget table custom query

Hi all, i've a widget that aims to show the latest casting like this:
class LatestCastings extends BaseWidget
{
protected static ?int $sort = 2;

protected int|string|array $columnSpan = 'full';
public function table(Table $table): Table
{
return $table
->heading('Recent Castings')
->query(
Casting::query()->where('user_id', auth()->id())->latest()->take(5)
)
->columns([
....
class LatestCastings extends BaseWidget
{
protected static ?int $sort = 2;

protected int|string|array $columnSpan = 'full';
public function table(Table $table): Table
{
return $table
->heading('Recent Castings')
->query(
Casting::query()->where('user_id', auth()->id())->latest()->take(5)
)
->columns([
....
but Casting::query()->where('user_id', auth()->id())->latest()->take(5) seems not work
1 Reply
ocram82
ocram824mo ago
I'm experiencing that inside ->query(...) i can't use take() or limit(). Maybe the reason is that they only are available in the collection and not in query Builder? Sounds weird....how can i limit the result with query builder inside ->query() function?