Laravel将select标签添加到我的控制器中

时间:2017-05-28 21:46:31

标签: php

这是我的选择标记

<select name="pointure" class="simple-text2" id="pointure">
    <option value="0">
        Tailles disponibles: 
    </option>
    @foreach($points as $point)
        <option value="{{$point->pointure}}">
            {{$point->pointure}}
        </option>
    @endforeach
</select>

这是我的路线档案

Route::get('/', 'Front@index');

Route::get('/affich/{nomChaussure}/{marque}/{couleur}','Front@showShoe')->name('shoe.show');

Route::get('/ajoute/{idClient}/{nomChaussure}/{marque}/{couleur}','Front@addPanier')->name('shoe.add');

Route::get('/recher',['uses' => 'Front@searchShoe','as' => 'search']);

Route::get('/achat/{idClient}/{nomChaussure}/{marque}/{couleur}','Front@buyShoe') -> name('shoe.buy');

Route::get('/afficher/{genre}/{categorie}','Front@showShoes')->name('shoes.show');

Route::get('/afficherM/{marque}','Front@showShoesMark')->name('shoesMark.show');

Route::get('/profil/{id}','Front@getProfil')->name('profil.show');

我有一个名为Front的控制器,我希望在Front控制器上获取所需的标签值,我需要帮助

1 个答案:

答案 0 :(得分:0)

以下是一个简单的示例,说明如何使其工作:

路线:

Route::get('/to-front-controller', 'FrontController@handleData');

刀片:

<form method="POST" action="/to-front-controller">
    <select name="pointure" class="simple-text2" id="pointure" onchange='this.form.submit()'>
        <option value="0">
            Tailles disponibles: 
        </option>
        @foreach($points as $point)
            <option value="{{$point->pointure}}">
                {{$point->pointure}}
            </option>
        @endforeach
    </select>
</form>

控制器:

class FrontController extends Controller 
{
    public function handleData(Request $request) 
    {
        dd($request->get('pointure'));
    }
}

这将输出pointure的任何值。