コード例 #1
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $post = Posts::findOrFail($id);
     if (empty($post)) {
         return Response::view('errors.404', array(), 404);
     }
     return View::make('/post/edit', array('post' => $post));
 }
コード例 #2
0
ファイル: PostController.php プロジェクト: Abenaman/ggc-talk
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $post = Posts::findOrFail($id);
     $validator = Validator::make($data = Input::all(), Posts::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $post->update($data);
     return Redirect::route('posts.index');
 }
コード例 #3
0
ファイル: PostTest.php プロジェクト: Abenaman/ggc-talk
 public function testStore()
 {
     $post = new Posts();
     $post->id = 123;
     $post->title = 'GGC Test Post!';
     $post->temp_username = '******';
     $post->message = 'This is a fake data blah blah blah';
     $post->topic_id = 1651;
     $post->save();
     Posts::findOrFail($post->id);
 }