/** * Show one blog post * GET * * @param int $id * @param string $title * @return Response */ public function showBlog($id, $title) { $blog = BlogManager::find($id); $nextBlog = BlogManager::find($blog->id + 1); $prevBlog = BlogManager::find($blog->id - 1); $comments = BlogCommentManager::join('accounts', 'accounts.guid', '=', 'cms_blogs_comments.author')->where('blog_id', $blog->id)->orderBy('date', 'desc')->paginate(10); $countComments = BlogCommentManager::where('blog_id', $blog->id)->count(); return view('home.blog', compact('blog', 'comments', 'nextBlog', 'prevBlog', 'countComments')); }
public function store(Requests\Blog $request) { $destinationPath = 'uploads'; $imgName = str_shuffle('affkldfnkjdfbjhbjhfdhjfsdkjfjkshgjfkhkj') . '_' . time(); $allData = $request->all(); if ($request->file('img')->isValid()) { $extension = $request->file('img')->getClientOriginalExtension(); $request->file('img')->move($destinationPath, $imgName . '.' . $extension); } Blog::create(['name' => $allData['name'], 'model' => $allData['model'], 'email' => $allData['email'], 'price' => $allData['price'], 'pass' => $allData['pass'], 'img' => $imgName . '.' . $extension]); return redirect()->back()->with('message', 'New Data Saved Successful'); }