/** * 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; }
public function getPost($slug) { $post = Post::where('slug', $slug)->firstOrFail(); return view('blog.show', compact('post')); }
/** * 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.'); }