last day (14 days later) » 

6:21 AM
Hello!
 
hey!
so it seems like you cannot post to the correct route at all now
what's your route looks like currently?
 
Yes bro I'm currently confused in my route.
I'll show you bro wait.
 
what about the form action?
<form class = "form-inline" method = "post" action = "{{ route ('document.pending', $list->id) }}"> <----
 
<form class = "form-inline" method = "post" action = "{{url('documents/pending/approve')}}">

<input type="hidden" name = "id" value = "{{$list->id}}">

<div class = "radio">
<label><input type = "radio" name = "status" value="approve"> Approve</label>
</div>

<div class = "radio">
<label><input type = "radio" name = "status" value="reject"> Reject</label>
</div>

</form>
Here bro I just followed what you said :D
 
hmm ok so what we wanan do now is to map the action to our controller
 
6:27 AM
Yes yes!! Should I need still to pass the $list->id in my action form?
 
do you happen to have any prefix in the url?
 
What bro I didn't get it. Can you elaborate?
 
yup the idea is that whenever that you have inside <form>...</form>, it will be sent over to the controller and you can access them using $request
what's the current url page that this is being shown?
 
I thought I'm not gonna use anymore a $request here when updating a column haha
/documents/pending/approve
 
okie let's try something
 
6:31 AM
Sure! Which where gonna start?
Hi Doom5!
 
add
Route::post('documents/approve', '\App\Http\Controllers\testApprove');
to your route file
then add to your controller
public function testApprove(Request $request)
{
dd($request->all());
}
oops i meant Route::post('documents/approve', '\App\Http\Controllers\DocumentsController@testApprove');
just append testApprove method to your existing DocumentsController
hey Doom5 :D
after that change your form action to action="{{url('documents/approve')}}"
and try update and see where it brings you
 
I tried this but I get the same error bro. When I didn't change the action to this action = "{{url('documents/pending/approve')}}" in loads me the view. But when I changed it I got an error.
 
Hello SteD, Francis. Isn't the controller path already namespaced? So there's no need for \App\Http\Controllers anymore?
Maybe that's what's causing the error?
 
aiks yeah!
 
What do you mean by already namespaced?
 
6:37 AM
From the docs
"Remember, by default, the RouteServiceProvider includes your route files within a namespace group, allowing you to register controller routes without specifying the full App\Http\Controllers namespace prefix. So, you only need to specify the portion of the namespace that comes after the base App\Http\Controllers namespace."
 
thanks man
Route::post('documents/approve', 'DocumentsController@testApprove');
when you change your action to action="{{url('documents/approve')}}" , what error you get now?
 
Oh I see didn't don't that still caused a error.
I still got a MethodNotAllowedHttpException.
 
Might need to see your whole routes file. Haha. Pastebin?
 
haha yeah...still couldn't map 'em together
 
Hahahaha please see again my routes file.
 
6:42 AM
ehh wait...where's your submit button?
<form class = "form-inline" method = "post" action = "{{url('documents/pending/approve')}}">

<input type="hidden" name = "id" value = "{{$list->id}}">

<div class = "radio">
<label><input type = "radio" name = "status" value="approve"> Approve</label>
</div>

<div class = "radio">
<label><input type = "radio" name = "status" value="reject"> Reject</label>
</div>

</form>
I dont see them inside the <form></form>
 
No I didn't want to use submit button here thats why? Hahaha. I just wanted to update it via radio button. But I think this is also a good solution to have a submit button.
 
so do you mean when you select one of the radio button, it should trigger the form update?
 
Seems like it. Haha.Maybe your form update code's not following your form's method attribute?
 
Yes! But if your solution is to have a button I would also accept it I think that is much better.
Yes I think that's why it doesn't update.
 
so if that's the case
<form class = "form-inline" method = "post" action = "{{url('documents/pending/approve')}}">

<input type="hidden" name = "id" value = "{{$list->id}}">

<div class = "radio">
<label><input type = "radio" name = "status" value="approve"> Approve</label>
</div>

<div class = "radio">
<label><input type = "radio" name = "status" value="reject"> Reject</label>
</div>
<input type="submit" value="submit">
</form>
and try clicking the button and see
btw you have some sort of javascript to trigger the form update when you click on the radio box?
 
6:48 AM
I still getting the same error :(
No I didn't have a javascript trigger.
 
hmm you selected the radiobox, then you click the submit button?
then only it submits the form?
 
Yes like that. But when I tried to load a view I didn't show. It throws me a error.
 
what error is it? :D
 
MethodNotAllowedHttpException huhuhu :(
 
can you screen shot that error page and see?
 
6:53 AM
Please see bro.
 
can I have a look at your whole blade file?
maybe paste it in pastebin.com or something
 
What happens when you replace url('documents/pending/approve') with route('documents.pending')?
 
It always shows me the error MethodNotAllowedHttp
 
Have you tried removing the App\Http\Controllers from your routes?
 
7:00 AM
For my second post? Yes I already removed it please see.
 
Update your other routes too.
 
Already did that but still getting the same..
 
How about your logs?
 
What do you mean logs?
 
Your log file. check storage/logs/laravel.log.
 
7:07 AM
They're so many haha
 
Just check the recent ones.
 
you can remove all the contents inside, and trigger the error again
to see the lastest one
 
So I will removed it?
 
yeah it's just your local machine laravel logs
 
It didn't show anything
 
7:14 AM
this is weird...
 
Yes me too I didn't know which part is getting the error.
 
hmm ok...let's see, load that page, right click -> view source and paste it in pastebin.com and let's see
 
oops I meant the page where you click the submit button
the view source of it
 
It didn't bring me to the view it always show's me the error
 
7:21 AM
ahhhhh!
ok just goto localhost:8000/documents/pending
is this the page where you select the radio box ?
 
Yes bro I got an error it says. Missing argument 2 for App\Http\Controllers\DocumentController::updateIsApprove()
I missed something in my updateIsApprove parameter
This my parameter looks like
public function updateIsApprove(Request $request, $document, $id)
{
$document = Document::find($id);

$document->isApprove = $request->status;

$document->save();

}
 
ok remove $document and $id from the parameters
public function updateIsApprove(Request $request)
and try again, what u get now?
 
NotFoundHttpException in compiled.php line 8858: HAHAHA what's this?
No I still got the error MethodNotAllowedHttpException
 
ok ok let's recap, you visit localhost:8000/documents/pending and you see a the table showing list of documents which u select approve / reject and click on submit right?
 
Yes yes exactly bro
 
7:28 AM
ok when u click submit, you get MethodNotAllowedHttpException?
 
Yes bro hahaha
Now I get undefined variable id when I submit the button. After adding $id in paramter and submit button I got .
Missing argument 2 for App\Http\Controllers\DocumentController::updateIsApprove()
After hitting the submit button it redirects me to /documents/pending/approve
 
yup sounds about right, and you see the MethodNotAllowedHttpException error there right?
 
Yes exactly bro hehe
 
so if u remove $id you get MethodNotAllowedHttpException?
you add $id you get Missing argument 2?
 
If i removed the id I got undefined variable. When I add $id I got missing argument 2 :D
 
7:32 AM
okie good! we're near
 
Yes yes!! :DDD
 
remove the $id
then you get undefined variable right
Document::find($request->id);
 
Yes I got that error.
 
change your find($id) to find($request->id)
 
It redirects me to blank page and it's not still updating hehe
 
7:34 AM
blank page is correct, becuase in your controller you just do a ->save() and not redirecting to anywhere
ok first line in your method, do a dd($request->all());
and what do you see?
 
Yes bro your right. But it's not updating in my db hehehe
Wait bro
I got
array:3 [▼
"id" => "3"
"status" => "approve"
"_token" => "Q58354gjX34MYgbofdYoTStBYPZIvOwc5hc7Z7hC"
]
 
what's your isApprove data type in your database?
can it accept 'approve' or 'reject'?
 
it's boolean bro. I already changed it to 1 and 0
No
 
document id = 3 is correct?
 
YES :D
 
7:38 AM
when you do $document->isApprove = $request->status;
you are actually passing $document->isApprove = 'approve';
 
Am I wrong here?
 
you can just do $document->isApprove = $request->status === 'approve' ? 1 : 0;
 
I tried this doom but it still not updating in my database
 
can you screenshot how you view your database?
 
here bro
 
7:44 AM
can you just try $document->isApprove = 1;
and see if it save successfully?
 
I'm so dumb hahaha I have a dd below that's why it's not working
it already working bro thanks!
this works!
$document->isApprove = $request->status;
Can I you update your answer? I need to go I'm already late. Thanks for your help!!
 
phew finally!
hahaha thanks to Doom5 as well
 

last day (14 days later) »