Vinciepincie's avatar

checkbox filter does not work with pagination. GET method not supported.

Hello. there's a checkbox, when clicked only finished transactions will show. This works fine without pagination. When i add pagination it shows "The GET method is not supported for this route. Supported methods: POST." when i click the checkbox and go to another page.

Livewire class:

class TransactionListPrivate extends Component
{

    public $receiveActiveOnly = true;
    public $sendActiveOnly = true;

    public function render()
    {
        //the user receives an item. Either by buying from someones else listing, or their own listing.
        $transactionsReceive = Transaction::orderBy('id', 'DESC')
        ->where(function (Builder $query) {
            return $query->where('transaction_type', 'buy')
                         ->where('user_id', Auth::user()->id);
        })
        ->orWhere(function (Builder $query) {
            return $query->where('transaction_type', 'sell')
            ->WhereRelation('listing', 'user_id', Auth::user()->id);
        })
        ->when($this->receiveActiveOnly, function ($query) {
            return $query->where('finished', 0);
        })->paginate(10, ['*'], 'receive');
        
        //the user receives currency.
        $transactionsSend = Transaction::orderBy('id', 'DESC')
        ->where(function (Builder $query) {
            return $query->where('transaction_type', 'sell')
                         ->where('user_id', Auth::user()->id);
        })
        ->orWhere(function (Builder $query) {
            return $query->where('transaction_type', 'buy')
            ->WhereRelation('listing', 'user_id', Auth::user()->id);
        })
        ->when($this->sendActiveOnly, function ($query) {
            return $query->where('finished', 0);
        })->paginate(10, ['*'], 'send');
        
        return view(
            'livewire.transaction-list-private',
            [
                'transactionsReceive' => $transactionsReceive,
                'transactionsSend' => $transactionsSend,
            ]
        );

    }
}

View:

@if ($transactionsReceive)
    <div class="form-check">
        <input type="checkbox" wire:model="receiveActiveOnly" class="form-check-input" 																		 
         id="receiveActiveOnly">
        <label class="form-check-label" for="receiveActiveOnly">Show open transactions only</label>
    </div>
    @foreach ($transactionsReceive as $transaction)
        ..
    @endforeach
    {{ $transactionsReceive->links() }}
    </div>
@endif
0 likes
1 reply

Please or to participate in this conversation.