I have a method to store and validate data from POST request, the first method works fine and validated successfully.
public function saveClientInfo(){
ClientInfo::create($this->validateClientInfo());
}
public function validateClientInfo(){
return request()->validate([
'code' => 'required',
're' => ['required','unique:client_infos'],
'name' => 'required',
'contact' => 'required',
'email' => 'required',
'property' => 'required',
'status' => 'required'
]);
}
Here in this second method with the same structure for saving and validating the requests, it doesn't work I'm very intrigue as to why.
public function loanStatus(){
PaymentInfo::create($this->validatePay());
}
public function validatePay(){
return request()->validate([
'payment_type' => 'required',
'terms' => 'required',
'amount_due' => 'required',
'from' => 'required',
'to' => 'required'
]);
}
By the way they're in the same controller so I dont get nauseous trying to figure out what is the difference of both as to where I went wrong.
NOTE:
the error it gives is Route GET is not Supported suggested Method POSTS some sort of like this,
that's why it's confusing enough already I checked the form and routes and I used post so why this error is showing so I figure it must be the request validate part.
Blade File
<form action="/proceed/loan-status" method="POST">
@csrf
<input type="hidden" name="re" value="{{ $re }}">
<div class="row">
<div class="p-2">
<input type="text" class="form-control" name="payment-type" placeholder="Payment Type...">
@if($errors->has('payment_type'))
<p class="alert text-danger">{{ $errors->first('payment_type') }}</p>
@endif
</div>
<div class="p-2">
<input type="text" class="form-control" name="terms" placeholder="Terms...">
</div>
<div class="p-2">
<input type="number" min="2" max="" step="any" class="form-control" name="amount" placeholder="Amount Due...">
</div>
<div class="p-2">
<input type="text" class="form-control" name="from" placeholder="From...">
</div>
<div class="p-2">
<input type="text" class="form-control" name="to" placeholder="To...">
</div>
</div>
</div>
<div class="card-footer d-flex justify-content-between">
<button type="submit" class="btn btn-success btn-sm">Save</button>
<a href="/" class="btn btn-danger btn-sm">Cancel</a>
</div>
</form>
web.php
Route::post('/proceed/loan-status', 'ClientInfoController@loanStatus');