Laravel - How to call a different action from store,update, Edit?

Asked

Viewed 722 times

2

I created a action without being the standard of resource, how can I call the same for an action on form as I call the update and store.

<form method="POST" role="form" action="{!!URL::route('cadastro.store')!!}" >

I want to call a query when click example

<form method="POST" role="form" action="{!!URL('cadastro.consulta')!!}">
  • What is the name of Controller and what is the name of the Method (Action)?

  • register Control and the action I want to call and query, public Function search(Request $request) { $name= $request['name']; $clients= registrationClient:: Where('name','like', "%".$name."%")->get(); Return view('clients.index', Compact('clients')); }

  • Okay, I believe that’s it !!!

1 answer

2


Open the route file and create a Route::post as follows:

Route::post('consulta', [
    'as' => 'cadastro.consulta', 
    'uses' => 'cadastrarController@pesquisar']
);

Reference:

  • 1

    do action="{!! URL::route(register.search')!! }" ? or have any changes?

  • you have to put the setting that is in the key 'as' that in the case I put in response cadastro.consulta consequently action="{!!URL::route('cadastro.consulta')!!}". If you want to change the name just change the key 'as' !!!

  • It worked, can you explain me? I didn’t find anything like that around

  • Do you have any specific questions? for example this as and uses are well explained in this link. Depending on the version in the documentation there is no explanation, but in the old ones it has that was this link that I posted for you.

  • the use must be a unique name, to be assigned in your call route('nome_da_rota').

Browser other questions tagged

You are not signed in. Login or sign up in order to post.