-1

I have page that i reach it from post route :

Route::post('/daily', [App\Http\Controllers\AdminController::class, 'daily'])->name('daily');

in this page i have icon which have action of update data by get method :

<td class="text-center notforprint"> <a href="{{route('abs_action',["id"=>$item->id,"action"=>'edit','date'=>$absences[0]->date,'stage'=>$stage,'group'=>$absences[0]->group])}}"><i class="fas fa-check-circle"></i></a></td>

in 'abs_action' controller I update data and want return back to same page with array that the page need:

return back()->with($arr);

I get this error : The GET method is not supported for this route. Supported methods: POST.

How can I solve it and return to same page

Sermed mayi
  • 697
  • 7
  • 26
  • 3
    As a general rule: To show views, always use `GET` routes. To add/updated/delete actions, go for POST (POST/PUT/PATCH/DELETE). – Kenny Horna Oct 05 '21 at 16:45

1 Answers1

0

Solution:- as @Kenny Horna mentioned I changed get method to put

before :

<td class="text-center notforprint"> <a href="{{route('abs_action',["id"=>$item->id,"action"=>'edit','date'=>$absences[0]->date,'stage'=>$stage,'group'=>$absences[0]->group])}}"><i class="fas fa-check-circle"></i></a></td>

after :

<td class="text-center notforprint"> 
      <form action="{{route('abs_action')}}" method="POST">
         {{ method_field('PUT') }}
         {{ csrf_field() }}
         <input type="hidden" name="date" value="{{$absences[0]->date}}">
         <input type="hidden" name="stage" value="{{$absences[0]->stage}}">
         <input type="hidden" name="group" value="{{$absences[0]->group}}">
         <input type="hidden" name="id" value="{{$item->id}}">
         <input type="hidden" name="action" value="edit">
         <button type="submit" class="btn btn-primary">
         <i class="fas fa-check-circle"></i>
         </button>
      </form>
 </td>
Sermed mayi
  • 697
  • 7
  • 26