Laravel 5 Can't send data from url

294
May 24, 2017, at 12:12 PM

Hi Im currently trying to make a basic crud for my questions resource on laravel 5

so far so good, but now Im having troubles displaying the edit view, because the url is not being created correctly when I try to send the resource id in the url

here's the anchor Im using

<a href="{{route('admin/questions/update',$question->id)}}"><button class="submit-form button button btn btn-primary" style="margin: 0 1em;" type="submit">Editar</button></a>

here's the route in my routes file

Route::get('admin/preguntas/editar/{id}','QuestionsController@edit')->name('admin/questions/update');

the method in the controller works just fine, when I manually type this url

/admin/preguntas/editar/4

It shows the view without problems, but when I go from the anchor the url it goes is this one

/admin/preguntas/editar?4

of course the 4 is the id from my resource, but why is not typing the correct url?

thanks in advance

Answer 1

And your "QuestionsController@edit" accepts "id" argument? like

function edit($id){}

And I think, your are using wrong route link helper

Route::get('user/{id}/profile', function ($id) {
    //
})->name('profile');
$url = route('profile', ['id' => 1]);
Answer 2

You can't wrap a hyperlink around a button so my assumption is your problem is related to the form action (since button type is submit), not the a href.

Since it appears you're using bootstrap, there is no need to use a button to get the styling of a button.

<a class="btn btn-primary"> will work just fine.

Rent Charter Buses Company
READ ALSO
javascript (jQuery) - Single script is not working my in my 2 separate page

javascript (jQuery) - Single script is not working my in my 2 separate page

I have two separate pages : issuance_filterphp and memo_list

223
how to get the hcsr04 ultrasonic sensor distance on desktop via php

how to get the hcsr04 ultrasonic sensor distance on desktop via php

I want to get the distance from the HC-Sr04 ultrasonic sensor and the color of the led light displayed on my laptop via PHP can anyone please help i am stuck hereThanks in advance

297