示例#1
0
 /**
  * Edit page (post).
  *
  * @Post("edit/{hash}", as="user.pastebin.edit")
  *
  * @param string $hash
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function postEdit($hash)
 {
     $pb = $this->pasteBin->whereHash($hash)->get()->first();
     if (!isset($pb)) {
         abort(404);
     }
     if ($pb->user_id !== $this->user_id) {
         return redirect('user/pastebin')->with('message', 'そのメモはあなたのメモではありません。');
     }
     $pb->description = $this->request('description');
     $pb->code = $this->request('code');
     $validate = $this->pasteBin->validate($pb->toArray());
     if ($validate->fails()) {
         return redirect()->back()->withErrors($validate->errors());
     }
     $pb->update();
     return redirect("user/pastebin/edit/{$hash}")->with('message', '更新しました。');
 }