I'm new to Laravel and what i'm trying here is to simply get the input form values and display it with dd function.
routes file:
Route::get('/', [
'as' => 'index',
"uses" => "IndexController@index"
]);
Route::get('/panier',[
"uses" => "ProductController@addToCard"
]);
My form :
<form method="get" action"/panier">
<table>
<tr>
<td>
Nombre de serveurs physiques
</td>
<td>
<select id="nb_serveurs" name="nb_serveurs"><option value="0">Choisir une option</option><option value="1" selected="selected" >1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option></select>
</td>
</tr>
<tr>
<td>
Type de licence
</td>
<td>
<select id="type" name="type"><option value="0">Choisir une option</option><option value="1" selected="selected" >Illimitée</option><option value="2">Standard</option></select>
</td>
</tr>
<tr>
<td>
Durée
</td>
<td>
<select id="duree" name="duree"><option value="0">Choisir une option</option><option value="1" selected="selected">1 an</option><option value="2">2 ans</option><option value="3">3 ans</option></select>
<a class="reset_variations" href="#">Effacer</a>
</td>
</tr>
</table>
<div style="width:100%;height:50px;">
<div class="price"><span id="total">495,00 € HT</span></div>
</div>
<div class="panier-button">
<input type="submit" class="single_add_to_cart_button button alt joli-boutton" id="panier-go" value="Ajouter au panier"/>
</div>
</form>
And the controller :
class ProductController extends Controller
{
public function addToCard (Request $request){
$input = Input::all();
dd($input);
}
}
the get works because when i submit the form my URL goes like this :
But shouldn't it be like this ?
and why the dd function doesn't work, it doesn't display anything ..
Sorry i'm a real newbie.
And 2nd question, how can i do this with post method, when i replace my route to post and the method form attribute it doesn't work.
Any ideas ?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire