Laravel 6.8 PUT Method not working for one of Controller, Showing Blank Page
Any suggestion or solution are most welcome. Following are summery of code. Route Pointer is not going under Controller update function
HTML edit.blad.php ( I tested with {{ method_field('PUT') }} )
<form class="form-horizontal" action="{{ route('certificate.update',$certificate_data->id) }}" method="post">
{{ csrf_field() }}
<input type="hidden" name="_method" value="PUT">
// Other Form Fields
</form>
web.php ( Route File )
Route::group(['prefix' => 'admin'], function(){
Route::resource('certificate', 'CertificateController');
});
php artisan route:list http://prntscr.com/qf662i
this is output of route:list
Controller Function
public function update(Request $request, Certificate $certificate)
{
echo 'vvvvv';
return $certificate;
return $input = $request->all();
}
Pointer not coming into controller update and showing only blank page I also tested with all function into the controller
For reference -> If I change web.php and do following code then pointer is coming there. But not into Controller update function.
Route::put('certificate/{certificate}', function ($certificate) {
return $certificate;
})->name('certificate_update');
As per your code everything looks good.
Reason for pointer not going into controller from route file
Your Path OR Name of controller is wrong / mismatched
Controller file is called from another place
Question
If answer is YES then it might be possible that wrong controller from backup is called from laravel cache. REMOVE Those backup files and Folders from controller folder.
Solution
I think controller PATH is cached and wrong controller is called instead. Try following commands to clear general cache.
php artisan cache:clear
php artisan route:cache
php artisan config:cache
php artisan view:clear
To clear controller file / path cache. We'll have to regenerate autoload.
Try following command. (This step is important)
composer dumpautoload
If this solves your issue then you can use normal html edit.blade form syntax as following.
<form action="{{ route('certificate.update',$certificate_data->id) }}" method="post">
{{ csrf_field() }}
{{ method_field('PUT') }}
// Other form fields
</form>
On your controller. Your normal code should work like following.
public function update(Request $request, Certificate $certificate)
{
return $certificate;
}
Let me know if this process helps you. Good luck.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With