add csrf_token into your form.
{{csrf_field}}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
this my view page button when we click on it it goes to controller method to update the one column of table
<button onclick="location.href='{{ URL('recruiter/shortlistt/'.$dd->jobseekers_unique_id) }}'" class="col-md-5 col-sm-5 btn btn-success">Shortlist</button>
this is my route
Route::post('shortlistt/{id}','RecruiterController@shortlisted');
and this is my controller
public function shortlisted($id,Request $request)
{
// return 'hello';
// dd($request->all());
$candidate = AppliedJob::where('jobseekers_unique_id',$id)->firstOrFail();
// dd($candidate);
$candidate->recruiter_status = 'shortlisted';
$candidate->update();
return redirect('/recruiter/applied-candidates');
}
How to solve this error.
add csrf_token into your form.
{{csrf_field}}
url helper function use get request that's a problem here change like this..
Route
Route::post('shortlistt/{id}','RecruiterController@shortlisted')->name('shortlist.update');
Blade file
<button onclick="location.href='{{ route('shortlist.update', ['id' => $dd->jobseekers_unique_id]) }}'" class="col-md-5 col-sm-5 btn btn-success">Shortlist</button>
@biishmar bro getting same error I changed as you said but it showing again same error this is my view page
<section class="panel">
@foreach($details as $dd)
<div class="panel-body profile-information row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-2">
<div class="profile-pic text-center">
<img src="{{asset('s3/images/user.png')}}" alt="">
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="profile-desk">
<h1>{{ $dd->first_name }}</h1>
<span class="text-muted">Experience:{{ $dd->total_years_of_work_exp }}</span>
<div class="row">
<div class="col-sm-12 col-md-6">
<h4>Applied For:</h4>
<h5><strong>{{ $dd->job_title }}</strong></h5>
<h6><strong>Applied On:</strong> {{ $dd->applied_date }}</h6>
</div>
<div class="col-sm-12 col-md-6">
<h4>Skills:</h4>
<h6><span><strong>{{ $dd->skills }}</strong></span></h6>
</div>
</div>
<input type="hidden" name="_token" value="{{csrf_token()}}">
<a href="#" class="col-md-5 col-sm-5 btn btn-primary">View Profile</a>
<a href="#" class="col-md-1 col-sm-1"></a>
<button onclick="location.href='{{ route('shortlist.update', ['id' => $dd->jobseekers_unique_id]) }}'" class="col-md-5 col-sm-5 btn btn-success">Shortlist</button>
</div>
</div>
</div>
@endforeach
</section>
@rin4ik this I used but it showing same error
<input type="hidden" name="_token" value="{{csrf_token()}}">
get it what's a problem is, change route file like this
Route
Route::get('shortlistt/{id}','RecruiterController@shortlisted')->name('shortlist.update');
seems like u r displaying the detail, that button redirect to update page not updating your detail..
I changed it but it taking some other route
Route::get('shortlistt/{id}','RecruiterController@shortlisted')->name('shortlist.update');
its shwoing the url like this by taking different route
http://localhost:8000/recruiter/applied-candidates
with this error
Sorry, the page you are looking for could not be found.
{{ method_field('POST') }}
What r u trying to do by clicking that button? updating a profile or redirecting to update page..
getting same error again I am trying to update a single column form a table when we press shortlist button
this is my view page
@extends('recruiter.recruiter-dashboard')
@section('title')
Applied Jobs by {{ucwords(Auth::user()->first_name)}}
@endsection
@section('recruiter-styles')
<meta name="csrf_token" content="{ csrf_token() }" />
<style>
.profile-information .profile-desk {
padding-right: 1px!important;
padding-bottom: 0px;
}
.profile-information .profile-desk span, .profile-information .profile-desk p {
padding-bottom: 0px;
}
</style>
@endsection
@section('recruiter-page')
<div class="row">
<div class="col-md-12">
<div class="text-center">
<h3 class="color-terques"> </h3>
</div>
<section class="panel">
@foreach($details as $dd)
<div class="panel-body profile-information row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-2">
<div class="profile-pic text-center">
<img src="{{asset('s3/images/user.png')}}" alt="">
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="profile-desk">
<h1>{{ $dd->first_name }}</h1>
<span class="text-muted">Experience:{{ $dd->total_years_of_work_exp }}</span>
<div class="row">
<div class="col-sm-12 col-md-6">
<h4>Applied For:</h4>
<h5><strong>{{ $dd->job_title }}</strong></h5>
<h6><strong>Applied On:</strong> {{ $dd->applied_date }}</h6>
</div>
<div class="col-sm-12 col-md-6">
<h4>Skills:</h4>
<h6><span><strong>{{ $dd->skills }}</strong></span></h6>
</div>
</div>
{{ method_field('POST') }}
<!-- <input type="hidden" name="_token" value="{{csrf_token()}}"> -->
<a href="#" class="col-md-5 col-sm-5 btn btn-primary">View Profile</a>
<a href="#" class="col-md-1 col-sm-1"></a>
<button onclick="location.href='{{ route('shortlist.update', ['id' => $dd->jobseekers_unique_id]) }}'" class="col-md-5 col-sm-5 btn btn-success">Shortlist</button>
</div>
</div>
</div>
@endforeach
</section>
</div>
</div>
@endsection
@section('recruiter-scripts')
@endsection
I am trying that I have one view page where it shows all the details of candidates with two button one is view profile and one is shortlist button when recruiter click that shortlist button then it goes to a particular controller method from which it check the id of particular jobseeker form applied_job table and if it found then it update a particular column which is recruiter_status to shortlisted.
this is my controller method for this
public function shortlisted($id,Request $request)
{
// return 'hello';
// dd($request->all());
$candidate = AppliedJob::where('jobseekers_unique_id',$id)->firstOrFail();
// dd($candidate);
$candidate->recruiter_status = 'shortlisted';
$candidate->update();
return redirect('/recruiter/applied-candidates');
}
Are u sure that u use post request?
Change your button with a form
<form method='post' action="{{ route('shortlist.update', ['id' => $dd->jobseekers_unique_id]) }}">
{{ csrf_field() }}
<button type='submit' class="col-md-5 col-sm-5 btn btn-success">Shortlist</button>
</form>
yes change it to form
this will solve ur problem..
yes its post request I used like you said but it taking some other route behalf of shortlist.update it take applied-candidates route I don't know what happend.
I change it to form but taking different route Instead of shortlist.update .
<form method='post' action={{ route('shortlist.update', ['id' => $dd->jobseekers_unique_id]) }}>
{{ csrf_field() }}
<button type='submit' class="col-md-5 col-sm-5 btn btn-success">Shortlist</button>
</form>
This is the route, for update you should use patch request.
Route::patch('shortlistt/{id}', 'RecruiterController@shortlisted')->name('shortlist.update');
This is the form
<form method='post' action="{{ route('shortlist.update', $dd->jobseekers_unique_id) }}">
{{ csrf_field() }} {{ method_field('PATCH') }}}
<button type='submit' class="col-md-5 col-sm-5 btn btn-success">Shortlist</button>
</form>
location.href is a GET REQUEST!
check your route..
You get MethodNotAllowedHttpException error when request method does not match or not allowed in your routes. In this case, your button is opening a URI with GET method but your route definition is for POST. So you need to fix either blade file (create a form) or change method to GET in your routes file.
@Sergiu17 @biishmar @rin4ik @Jackrotto thank you all know its update my column but after the updation it not redirect to same page .
It is my controller
public function shortlisted($id,Request $request)
{
// return 'hello';
// dd($request->all());
$candidate = AppliedJob::where('jobseekers_unique_id',$id)->firstOrFail();
// dd($candidate);
$candidate->recruiter_status = 'shortlisted';
$candidate->save();
return view('recruiter.applied-candidates');
}
till save method it working but when I going to return same page it nothing shows me .
return redirect()->back();
@rin4ik Thanky you its working know.
@Sergiu17 bro It have some problem it give as same jobseeker id so it update on only jobseeker_status as shortlisted.
so how I can solve this.
create another disscussion
@rin4ik okk
@Sergiu17 bro how to pass two id like I want to pass here $dd->job_unique_id as well
<form method='post' action={{ route('shortlist.update', ['id' => $dd->jobseekers_unique_id]) }}>
{{ csrf_field() }} {{ method_field('PATCH') }}
<button type='submit' class="col-md-5 col-sm-5 btn btn-success">Shortlist</button>
</form>
<form method='post' action={{ route('shortlist.update', ['id' => $dd->jobseekers_unique_id, 'another_id'=>$dd->job_unique_id ]) }}>
{{ csrf_field() }} {{ method_field('PATCH') }}
<button type='submit' class="col-md-5 col-sm-5 btn btn-success">Shortlist</button>
</form>
Please or to participate in this conversation.