Example #1
0
 public function anyDetail($id)
 {
     $blogs = Blogs::find($id);
     $relate_blogs = Blogs::limit(3)->get();
     $comments = $blogs->comments;
     return view("news.detail")->withBlogs($blogs)->withComments($comments)->withRelateBlog($relate_blogs);
 }
Example #2
0
 public function postIndex(Request $request)
 {
     if (!$request->input("id")) {
         return;
     }
     $rs = Blogs::find($request->input("id"));
     return json_encode($rs);
 }
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     $menu_right_popular = Blogs::get();
     $menu_right_newest = Blogs::orderBy("id", "desc")->get();
     $menu_right_comment = Comment::all();
     $blog_bottom_footer = Blogs::limit(3)->get();
     view()->share(['menu_right_popular' => $menu_right_popular, 'menu_right_newest' => $menu_right_newest, 'menu_right_comment' => $menu_right_comment, "current_lang" => Session::get("current_lang"), "blog_bottom_footer" => $blog_bottom_footer]);
 }
 public function show($id)
 {
     $rs = Blogs::find($id);
     if (!$rs) {
         echo json_encode(["blog_title" => "Not found", "blog_content" => "Not found"]);
         return;
     }
     $comment = Comment::where("comment_blogs_id", $id)->get();
     echo json_encode(["blog_title" => $rs->blog_title, "blog_content" => $rs->blog_content]);
     die;
 }
 public function save_blog(Request $request)
 {
     $image = $request->file('blog_image');
     //        echo '<pre>';
     //        print_r($image);
     //        exit();
     if ($image) {
         $image_name = str_random(20);
         $ext = strtolower($image->getClientOriginalExtension());
         $image_full_name = $image_name . '.' . $ext;
         $destination_path = 'blog_images/';
         $image_url = $destination_path . $image_full_name;
         $success = $request->file('blog_image')->move($destination_path, $image_full_name);
         if ($success) {
             $blog = new Blogs();
             $blog->category_id = $request->category_id;
             $blog->blog_title = $request->blog_title;
             $blog->blog_short_description = $request->blog_short_description;
             $blog->blog_long_description = $request->blog_long_description;
             $blog->publication_status = $request->publication_status;
             $blog->author_name = Session::get('admin_name');
             $blog->blog_image = $image_url;
             $blog->save();
             Session::put('message', 'Save Blog Information Successfully !');
             return redirect('/add-blog');
         }
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     if (Blogs::find($id)->delete()) {
         return redirect($this->prefix_redirect . '/blogs/');
     }
 }