1
私はedit_Item機能を作りたいと思っていますが、編集したフォームを送信するときにルーティングに少し問題があります。私はこのエラーを取得する:ルート内で2つのパラメータを渡す方法はありますが、Laravelでは1つのパラメータを非表示にする方法はありますか?
InvalidArgumentException in UrlGenerator.php line 314:
Route [userItems] not defined.
まず第一に、私の編集ページで、私は、コントローラにアイテムテーブルから2つの引数(のitem_idとUSER_ID)を渡しフォームを持っており、それは次のようになります。
{!! Form::model($items, ['action' => ['[email protected]', $items->id, $items->user_id], 'method' => 'PUT']) !!}
//Form inputs
{{ Form::close() }}
私の更新コントローラは、次のようになります。
public function update($id, $user_id){
// validate
// read more on validation at http://laravel.com/docs/validation
$rules = array(
'title' => 'required',
'description' => 'required|description',
);
// store
$items = Item::find($id);
$items->title = Input::get('title');
$items->description = Input::get('description');
$items->save();
// redirect
Session::flash('message', 'Successfully updated item!');
return Redirect::route('userItems');
}
および更新方法と私のルートは次のようになります。
今10Route::put('/userItems/{id}/{user_id}', '[email protected]');
、私が提出したときに、私は現在にルーティング取得しています:
http://localhost:8000/userItems/26/3
そして、私はにルーティングを取得する必要があります(
http://localhost:8000/userItems/3
のitem_idを作成する方法上の任意のアイデア26)は経路から消えますか?
ありがとう、これは私の問題の解決策のように見えます。しかし、あなたの提供する例を使ってコードを編集したとき、私は今エラーを出しています:** UrlGenerator.php行のInvalidArgumentException 314: Route [items/userItems]が定義されていません** 私のuserItemsビューをitemsフォルダは、そのルートがitems/userItemsである理由です。 – Mindaugas
より具体的に質問を編集できますか?フォームを投稿するとき、または特定のURLにアクセスしようとするときにこのエラーが発生しますか? – Wistar
私はフォームを投稿/投稿するとこれを取得します。 ** http:// localhost:8000/userItems/5 **このエラー:** UrlGenerator.php行のInvalidArgumentException 314:Route [items/userItems]が定義されていません** Evenしかし、URLは機能するはずです。 – Mindaugas