Esempio n. 1
0
 /**
  * Return the field values from the model
  * 
  * @param integer $id
  * @param array $fields
  * @return array
  */
 protected function fieldsFromModel($id, array $fields)
 {
     $post = Post::findOrFail($id);
     $fieldNames = $fields;
     $fields = ['id' => $id];
     foreach ($fieldNames as $field) {
         $fields[$field] = $post->{$field};
     }
     return $fields;
 }
Esempio n. 2
0
 public function getPost($slug)
 {
     $post = Post::where('slug', $slug)->firstOrFail();
     return view('blog.show', compact('post'));
 }
Esempio n. 3
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $post = Post::findOrFail($id);
     $post->delete();
     return redirect()->route('admin.blog.post.index')->withSuccess('Post deleted.');
 }