because of a tag a with path "path / {{$ var}} / edit" and an 'action': "path / {{$ var}} my final path is:" "path / {{$ var }} / "Path / {{$ var}}"?

1

I have a view in Laravel with the following code:

<h1>Edicion</h1>
@foreach ($usuarios as $usu)
  <h4>{{$usu->nombre}}</h4>
  <a href="prurequests/{{$usu->slug}}/edit">editar</a>
@endforeach

A controller:

Route::resource('/prurequests','PruebasControllers\PrurequestsController'); 

With edit method:

public function edit($slug)
{
  $usuario = Usuario2::where('slug','=',$slug)->firstOrFail();
  return view('vistaspruebas.edit', compact('usuario'));
}

When I get to this view, my URL is: / public / prurequests / vaca / edit

in this view I have this code

<form action="prurequests/suma method="POST">
  @method('PUT')
  @csrf
  <label for="nombre">ingrese nombre</label>
  <input type="text" name="nombre" value="{{$usuario->slug}}">
  <br />
  <button type="submit" name="" value="submit">Actualiza</button>
</form>

and Laravel instead of looking for that route: "prurequests / suma" look for this / public / prurequests / cow / prurequests / suma

Does anyone know why after that tag and call another route I remove the 'edit' and change it by whatever route I put?

    
asked by Diego Izquierdo Dussan 12.08.2018 в 05:37
source

2 answers

0

You must use the laravel helpers:

<form action="{{url('prurequests/suma')}}" method="POST">
   @method('PUT')
   @csrf
   <label for="nombre">ingrese nombre</label>
   <input type="text" name="nombre" value="{{$usuario->slug}}">
   <br />
   <button type="submit" name="" value="submit">Actualiza</button>
</form>
    
answered by 13.08.2018 / 21:24
source
0

The quote is missing after adding the form and adding the helpers

<form action="prurequests/suma method="POST">
  @method('PUT')
  @csrf
  <label for="nombre">ingrese nombre</label>
  <input type="text" name="nombre" value="{{$usuario->slug}}">
  <br />
  <button type="submit" name="" value="submit">Actualiza</button>
</form>

I should stay:

<form action="{{url('prurequests/suma')}}" method="POST">
  @method('PUT')
  @csrf
  <label for="nombre">ingrese nombre</label>
  <input type="text" name="nombre" value="{{$usuario->slug}}">
  <br />
  <button type="submit" name="" value="submit">Actualiza</button>
</form>

Or you could make your form this way:

Route::post('prurequests/suma', 'PrurequestsController@suma')->name('prurequests.suma');

{!! Form::open(['route' => 'prurequests.suma']) !!}

    <label for="nombre">ingrese nombre</label>
    <input type="text" name="nombre" value="{{$usuario->slug}}">
    <br />
    <button type="submit" name="" value="submit">Actualiza</button>

{!! Form::close() !!}
    
answered by 13.08.2018 в 20:29