Reputation: 63
I'm adding pagination to my view but for some reason the URL string includes a "_token" string. How can I remove that?
Here is How my controller looks like:
public function index($client_id, Request $request)
{
$client = Client::where('id', $client_id)->first();
if ($request->search) {
$extensions = Extension::query()
->where('first_name', 'like', '%'. $request->search .'%')
->where('client_id', 'like', '%'. $client_id .'%')
->paginate(5);
}else{
$extensions = Extension::where('client_id', $client_id)->paginate(5)->withQueryString();
}
return view("pages.extensions.index", compact('client', 'extensions'));
}
My index blade has this:
<!-- Top Bar -->
<div>
<form action="{{ route('extensions.index', [$client->id]) }}" method="GET">
@csrf
<x-input type="text" name="search" id="search" placeholder="Search by First Name..." />
<button type="submit">Search</button>
</form>
</div>
<!-- Table -->
// A table goes here
<!-- Pagination Link -->
<div>
{{ $extensions->links() }}
</div>
Here is how looks like the URL after I use the search:
http://127.0.0.1:8001/clients/1/extensions?_token=Cdri3a6GEEOe90I9niEmVI&search=frodo
Upvotes: 0
Views: 205
Reputation: 437
Try removing @csrf
from your form.
As your form is doing GET request the _token
is not needed at all.
Upvotes: 2