skip to Main Content

I have a route as:

Route::get('/edit/detail/{modelName}/{rowId}/{persId}',[AddPersInfoController::class,'editPersDetailTabs'])->name('edit_pers_detail');

and I’m calling it from a button in a table as:

Edit: This is the actual code on my page.

<td><a href="{{ route('edit_pers_detail',['Posting_history', $posting->id, $posting->pers_info_id] ) }}">
<button class="btn btn-icon btn-primary"> <i class="demo-pli-pencil fs-5"></i> </button>
 </a>
</td>`

In my AddPersInfoController class, I have a function:

public function editPersDetailTabs($modelName, $rowId, $persId){

  dd('Controller method executed');

  // Fetching record for editable components
  $model_name = 'AppModels\' . $modelName;
        
  $detail = $model_name::where('id', $rowId)->first();
  dd($detail);

  return view('Pages.Persdata.add_all', compact('detail',   'postingHist',));
}

The method editPersDetailTabs is not getting called because none of the dd() statements show anything.

I have another route and method in the same syntax as this one; the only difference is that this accepts 3 parameters while the other one accepts two.

Rest everything is same. At least the method is being called in the other one.

Whenever I click the button; it just refreshes the page. Nothing else happens.
I expect it to at least call the method.

Where could be the issue?

2

Answers


  1. Try explicitly defining the route parameter names as keys in the array:

    <a href="{{ route('edit_pers_detail',['modelName' => 'Posting_history', 'rowId' => $posting->id, 'persId' => $posting->pers_info_id] ) }}">
    
    Login or Signup to reply.
  2. $posting->id, ‘posting_person_info’ => $posting->pers_info_id] ) }}”>

    Route::get(‘/edit/detail/{Posting_history}/{posting_person_info}’,[AddPersInfoController::class,’editPersDetailTabs’])->name(‘edit_pers_detail’);
    public function functionName($Posting_history, $posting_person_info){
    }

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search