Reputation: 29
Queue.php
class Queue extends Component
{
public function Data()
{
$fgd = FaddddxO::where('seus',$this->stas)
->whereNu('achieve_by');
if ($this->filter == '' && $this->stus != 'x Error')
{
$fax->where(function ($query) {
$query->whereDate('created_at', Carbon::today())
->orwhereDate('d_datetime', Carbon::today());
});
} else if ($this->filter == 'ries'){
$fassssxSss->where('resd_ag','>=',3)->whereNull('archive_by');
} else if ($this->filter == 'ponse'){
$favfhdjdfh->where(function ($query) {
$query->whereDate('created_at','<=' ,Carbon::now()->subDays(3))
->orwhereDate('dvkjdvvbfshnd_datetime','<=' ,Carbon::now()->subDays(3));
})->whereNull('archive_by');
}
}
In the Data() function, paginate with toArray() method is working. But when trying to populate links() in blade file it's showing the below error.
And this is the error:
Call to a member function links() on array
Upvotes: 0
Views: 225
Reputation: 26450
The error is quite explicit, and is caused by this
$this->faxStatus = $faxStatusData->orderByDesc('id')->paginate(5)->toArray();
A PHP array does not have any methods to call on it. You need stop at paginate()
without any further casting if you want to keep the result paginated - by simply stopping with chaining more methods on after paginate()
- like this
$this->faxStatus = $faxStatusData->orderByDesc('id')->paginate(5);
If you need to access the data of the paginated result, you can access that at $this->faxStatus->items()
, without needing to cast it to an array.
If you - for whichever reason - need to convert it to an array, then you need to assign that to a different property, for example by doing
$this->faxStatus = $faxStatusData->orderByDesc('id')->paginate(5);
$this->faxStatusArray = $this->faxStatus->toArray();
And then accessing it as $this->faxStatusArray
. I would however think that you can achieve the same by accessing $this->faxStatus->items()
.
Upvotes: 1