I am trying to use multi language in my laravel 8 application frontend. I have used mcamara package, and set it up as per the guide on github.
I Have a form which accepts a input, which fetches the user. Based on the condition (if the user has taken survey, downloads a file. else shows the survey form and then redirects to download).
This is working absolutelyn fine in both languages. I am able to view the form in both languages, but once i enter the view page after id submission and i click on the language change button, i get this
SymfonyComponentHttpKernelExceptionMethodNotAllowedHttpException
The GET method is not supported for this route. Supported methods: POST.
The issue is only in the POST method. Rest works fine.
Can someone help me on how to fix this?
Thanks in advance.
My route file
Route::redirect('/', 'en');
Route::group(['prefix' => LaravelLocalization::setLocale()], function()
{
Route::get('/', function () {
return redirect()->route('certificate.download');
// return view('welcome');
});
// Frontend
Route::prefix('/registration')->group(function(){
Route::get('/add', [RegController::class, 'RegEnqAppAdd'])-> name('reg.add');
Route::get('signature_pad', [RegController::class, 'index']);
Route::post('signature_pad', [RegController::class, 'store'])->name('signature_pad.store');
Route::post('/store', [RegController::class, 'RegEnqAppAddStore'])-> name('reg.store');
});
// Frontend Downloads
Route::prefix('/downloads')->group(function(){
Route::get('/certificate', [DownloadController::class, 'DownloadCertificate'])-> name('certificate.download');
Route::get('/addcertificate/{id}', [DownloadController::class, 'AddCertificate'])-> name('certificate.add');
Route::get('/addcertificate/group/{id}', [DownloadController::class, 'AddCertificateGroup'])-> name('groupcertificate.add');
Route::post('/storecertificate', [DownloadController::class, 'StoreCertificate'])-> name('certificate.store');
Route::post('/viewcertificate', [DownloadController::class, 'ViewCertificate'])-> name('certificate.view');
Route::get('/viewcertificates/{id}', [DownloadController::class, 'ViewCertificateRedirect'])-> name('certificateredirect.view');
Route::get('/deletecertificate/{id}/{bid}', [DownloadController::class, 'DeleteCertificateBatch'])-> name('certificate.delete');
Route::get('/deletegroupcertificate/{id}/{gid}', [DownloadController::class, 'DeleteCertificateGroup'])-> name('groupcertificate.delete');
});
// Frontend Surveys
Route::prefix('/surveys')->group(function(){
Route::get('/post-training-questionaire/{id}', [SurveyController::class, 'PostTrainingQuestionaire'])-> name('surveys.posttraining');
Route::post('/post-training-questionaire/store', [SurveyController::class, 'PostTrainingQuestionaireStore'])-> name('surveys.posttrainingstore');
});
});
// Frontend Group
// Frontend Group
My Initial View File (id input)
@extends ('frontendlayouts.frontend_master')
@section ('frontendbody')
<script src="https://code.jquery.com/jquery-3.6.0.min.js"integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
{{-- <link href="//netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet"> --}}
<div class="content-wrapper">
<div class="container-full">
<div class="row">
<div class="col-md-12">
<div class="content-header">
<div class="d-flex align-items-center">
<div class="mr-auto">
<div>
<img src="{{ asset('backend/images/amilogo.png') }}" width="150px" alt="">
</div>
<h3 class="page-title" style="border-right: none;">Downloads - Certificate Download</h3>
<div class="align-items-center">
<nav>
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="#"><i class="mdi mdi-home-outline"></i></a></li>
<li class="breadcrumb-item active" aria-current="page">{{ __('Course Certificate') }}</li>
</ol>
</nav>
</div>
</div>
</div>
</div>
</div>
</div>
<section class="content">
<div class="box">
<div class="box-header with-border">
<h4 class="box-title">{{ __('Enter Your CPR Number to Download Your Certificates') }}</h4>
</div>
<form class="form" method="post" action="{{ route('certificate.view') }}" enctype="multipart/form-data" id="posttrainingquestionaire">
@csrf
<div class="box-body">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>{{ __('CPR Number') }}</label>
<input type="text" name="cprnumber" id="cprnumber" class="form-control" maxlength="9" placeholder="CPR Number" required data-validation-required-message="This field is required">
</div>
@error('cprnumber')
<span class="text-info">{{ $message }}</span>
@enderror
</div>
</div>
</div>
<div class="box-footer">
<button onclick="$('#posttrainingquestionaire').submit()" class="btn btn-rounded btn-primary btn-outline">
<i class="ti-save-alt"></i> {{ __('Submit & Download') }}
</button>
</div>
</form>
</div>
</section>
</div>
</div>
@endsection
My view_certificate view
@extends ('frontendlayouts.frontend_master')
@section ('frontendbody')
<script src="https://code.jquery.com/jquery-3.6.0.min.js"integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
<div class="content-wrapper">
<div class="container-full">
<div class="content-header">
<div class="d-flex align-items-center">
<div class="mr-auto">
<div>
<img src="{{ asset('backend/images/amilogo.png') }}" width="150px" alt="">
</div>
<h3 class="page-title" style="border-right: none;">Downloads - Certificate Download</h3>
<div class="align-items-center">
<nav>
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="#"><i class="mdi mdi-home-outline"></i></a></li>
<li class="breadcrumb-item active" aria-current="page">{{ __('Course Certificate') }}</li>
</ol>
</nav>
</div>
</div>
</div>
</div>
<section class="content">
<div class="box">
<div class="box-header with-border">
{{-- <h4 class="box-title">Enter Your CPR Number to Download Your Certificates</h4> --}}
<h1>{{ __('Welcome to Almoalem Institute') }}</h1>
</div>
<form class="form" method="post" action="{{ route('certificate.view' ) }}" enctype="multipart/form-data" id="posttrainingquestionaire">
@csrf
<div class="box-body">
<div class="row">
<div class="col-md-12">
<div class="timeline-event">
<div class="timeline-body">
<div class="media-body">
<div class="timeline-title"><strong>{{ __('CPR Number') }}:</strong></span> <span class="timeline-body">{{ $learnerData->cprnumber }}</span>
<br>
<span class="timeline-title"><strong>{{ __('Full Name') }}:</strong></span> <span class="timeline-body">{{ $learnerData->fullname }}</span></div>
<br>
<br>
</div>
</div>
</div>
<div class="col-12">
<div class="box">
<div class="box-body no-padding">
<div class="table-responsive">
<table class="table table-hover">
<tr>
<th>Sl. No</th>
<th>Course</th>
<th>Download Certificate</th>
</tr>
<?php $app =array(); ?>
@foreach($downloadData as $key => $dd)
<tr>
<td>{{ $key+1 }}</td>
<td>{{ $dd->applicationmanagement->courseapplied }}</td>
<td>
@if($dd->surveytaken!=NULL || in_array($dd->courseapplication_id, $app))
<?php $app[$key]=$dd->courseapplication_id;?>
<p class="text-black">
<a href="{{asset('certificate/'.$dd->certificate) }}" class="btn btn-primary md-5" target="_blank">{{ __('Download Certificate') }}</a>
</p>
@else
<a href="{{route('surveys.posttraining',$dd->id)}}" class="btn btn-dark md-5"> {{ __('Complete Training Feedback to Download Certificate') }}</a>
@endif
</td>
</tr>
@endforeach
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</section>
</div>
</div>
@endsection