これを行う最善の方法は感謝します
これが行うことは、フォームから入力を取得してデータベースに保存することです。
public function update()
{
$file = Input::file('path');
$destinationPath = 'img/';
$filename = $file->getClientOriginalName();
// $extension =$file->getClientOriginalExtension();
$upload_success = Input::file('path')->move($destinationPath, $filename);
$photo = Photo::find($_POST['id']);
$photo->caption = $_POST['caption'];
$photo->path = $destinationPath . $filename;
$photo->save();
if( $upload_success ) {
return Redirect::to('photos/'.$_POST['id'].'/edit')->withInput()->with('success', 'Photo have been updated.');
} else {
return Response::json('error', 400);
}
}
これは問題なく動作しますが、$_POST を使用してフォーム パースから id を取得し、フォーム パースから id を取得する代わりに、フォーム送信から更新して写真情報を更新する方法のように、これを行う簡単な方法があるかどうか疑問に思います。 update($id) など。ありがとう