dimanche 26 janvier 2020

MethodNotAllowedHttpException:The GET method is not supported for this route. Supported methods: POST

I am new to laravel and now i am facing an issue. I saw many related answers ,but nothing works for me. My problem is, i have a page and when i update a user i want to redirect on the same page with updated results.When i look into the db table,the updation is happening,but the page shows the above error. I tried many answers which i saw on stack , but nothing works for me.

Thank you

Here is my view:

<form method="POST"  action="/updateleaduser">

    @csrf

    <h6 style = "font-family:Palatino" class="card-text">Assigned To:&nbsp; </h6>
    <input type="hidden" name="idd" name="idd" value="">
    <select name="select_user" class="form-control">
        @foreach($testusers as $user) 
        <option value=""></option>
        @endforeach
    </select>
    <button type="submit" class="form-control" style="background-color: green;color: white;">Update User</button>

Here is my route:

Route::post('/updateleaduser','RequestController@updateuserlead')->name('updateleaduser');

Here is my controller:

public function updateuserlead(Request $request){
    $idd = $_POST['idd'];
    $select_user = $request->input('select_user');

    DB::table('leads')->where('id',$idd)->update(array(
        'client_id'=>$select_user,
    ));
    return redirect()->back();
}


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire