/** * @param Request $request * @param $comment_id * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function update(Request $request) { $comment_id = $request->input('comment_id'); $comment = Comments::where('id', $comment_id)->first(); $user = $request->user(); if ($user->is_admin() or $user->is_moderator() or $user->id == $comment->user_id) { $content = $request->input('content'); $comment->content = $content; $comment->save(); $product = Products::where('id', $comment->on_product)->first(); return redirect('/product/' . $product->slug); } else { redirect('/')->withErrors('You have not sufficient permissions'); } }
public function index($id = 0) { $categories = Categories::all(); $categories = $categories->sortBy('sort_id'); $item = Items::find($id); $comments = Comments::where('items_id', '=', $id)->get(); $data = ['categories' => $categories, 'item' => $item, 'id' => $item->categories_id, 'comments' => $comments]; return view('items.index', $data); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update(Request $request, $id) { $reading_id = Comments::where('id', $id)->first(); $redirectId = $reading_id->reading_id; $comment = Comments::findOrFail($id); $comment->comment = $request->comment; $comment->save(); return redirect("currently_reading/{$redirectId}"); }
public function show($slug) { $product = Products::where('slug', $slug)->first(); if ($product == NULL) { return redirect('/')->withErrors('Requested url does not exist'); } $comments = Comments::where('on_product', $product->id)->orderBy('created_at', 'asc')->paginate(5); $categories = Categories::all(); return view('product.show')->withProduct($product)->withCategories($categories)->withComments($comments); }
public function loadCommentsForPost($id) { $comments = Comments::where('post_id', $id)->orderBy('created_at', 'asc')->get(); // bidejkji vo baza chuvame samo ime na slika, Log::info($comments); foreach ($comments as $key => $comment) { $comment->user = User::find($comment->user_id); $imgName = $comment->user->profile_picture; $imgData = base64_encode(File::get('uploads/profile_pictures/thumbnails/' . $imgName)); $comment->user->profile_picture = $imgData; } return response()->json(['comments' => $comments]); }
public function dashboard() { // current month name // dd(date("F", mktime(0, 0, 0, Carbon::now()->month, 10))); // dd(Carbon::now()->subMonth()->startOfMonth()); // dd(date("F", mktime(0, 0, 0, Carbon::now()->subMonth()->startOfMonth()->month, 10))); $currentMonthStart = Carbon::now()->startOfMonth(); $subOneMonthStart = Carbon::now()->subMonth()->startOfMonth(); $subTwoMonthsStart = Carbon::now()->subMonth(2)->startOfMonth(); $subThreeMonthsStart = Carbon::now()->subMonth(3)->startOfMonth(); $subFourMonthsStart = Carbon::now()->subMonth(4)->startOfMonth(); $subFiveMonthsStart = Carbon::now()->subMonth(5)->startOfMonth(); $currentMonthEnd = Carbon::now()->endOfMonth(); $subOneMonthEnd = Carbon::now()->subMonth()->endOfMonth(); $subTwoMonthsEnd = Carbon::now()->subMonth(2)->endOfMonth(); $subThreeMonthsEnd = Carbon::now()->subMonth(3)->endOfMonth(); $subFourMonthsEnd = Carbon::now()->subMonth(4)->endOfMonth(); $subFiveMonthsEnd = Carbon::now()->subMonth(5)->endOfMonth(); $currentMonthTitle = date("F", mktime(0, 0, 0, Carbon::now()->startOfMonth()->month, 10)); $subOneMonthTitle = date("F", mktime(0, 0, 0, Carbon::now()->subMonth()->startOfMonth()->month, 10)); $subTwoMonthsTitle = date("F", mktime(0, 0, 0, Carbon::now()->subMonth(2)->startOfMonth()->month, 10)); $subThreeMonthsTitle = date("F", mktime(0, 0, 0, Carbon::now()->subMonth(3)->startOfMonth()->month, 10)); $subFourMonthsTitle = date("F", mktime(0, 0, 0, Carbon::now()->subMonth(4)->startOfMonth()->month, 10)); $subFiveMonthsTitle = date("F", mktime(0, 0, 0, Carbon::now()->subMonth(5)->startOfMonth()->month, 10)); $postsCurrentMonth = Posts::where('created_at', '>=', $currentMonthStart)->count(); $postsSubOneMonth = Posts::where('created_at', '>=', $subOneMonthStart)->where('created_at', '<=', $subOneMonthEnd)->count(); $postsSubTwoMonths = Posts::where('created_at', '>=', $subTwoMonthsStart)->where('created_at', '<=', $subTwoMonthsEnd)->count(); $postsSubThreeMonths = Posts::where('created_at', '>=', $subThreeMonthsStart)->where('created_at', '<=', $subThreeMonthsEnd)->count(); $postsSubFourMonths = Posts::where('created_at', '>=', $subFourMonthsStart)->where('created_at', '<=', $subFourMonthsEnd)->count(); $postsSubFiveMonths = Posts::where('created_at', '>=', $subFiveMonthsStart)->where('created_at', '<=', $subFiveMonthsEnd)->count(); $commentsCurrentMonth = Comments::where('created_at', '>=', $currentMonthStart)->count(); $commentsSubOneMonth = Comments::where('created_at', '>=', $subOneMonthStart)->where('created_at', '<=', $subOneMonthEnd)->count(); $commentsSubTwoMonths = Comments::where('created_at', '>=', $subTwoMonthsStart)->where('created_at', '<=', $subTwoMonthsEnd)->count(); $commentsSubThreeMonths = Comments::where('created_at', '>=', $subThreeMonthsStart)->where('created_at', '<=', $subThreeMonthsEnd)->count(); $commentsSubFourMonths = Comments::where('created_at', '>=', $subFourMonthsStart)->where('created_at', '<=', $subFourMonthsEnd)->count(); $commentsSubFiveMonths = Comments::where('created_at', '>=', $subFiveMonthsStart)->where('created_at', '<=', $subFiveMonthsEnd)->count(); // $posts = Posts::where('active','1')->where('archive','0')->orderBy('created_at','desc')->paginate(10); // $postsPending = Posts::where('active','0')->orderBy('created_at','desc')->get(); // $postsPendingCount = Posts::where('active','0')->count(); $popularPosts = DB::table('comments')->join('posts', 'posts.id', '=', 'comments.on_post')->where('posts.archive', '=', 0)->select(array('posts.title', DB::raw('COUNT(comments.on_post) as totalComments')))->groupBy('on_post')->orderBy('totalComments', 'desc')->take(10)->get(); return view('pages.dashboard', compact('currentMonthTitle', 'subOneMonthTitle', 'subTwoMonthsTitle', 'subThreeMonthsTitle', 'subFourMonthsTitle', 'subFiveMonthsTitle', 'postsCurrentMonth', 'postsSubOneMonth', 'postsSubTwoMonths', 'postsSubThreeMonths', 'postsSubFourMonths', 'postsSubFiveMonths', 'commentsCurrentMonth', 'commentsSubOneMonth', 'commentsSubTwoMonths', 'commentsSubThreeMonths', 'commentsSubFourMonths', 'commentsSubFiveMonths', 'popularPosts')); }
public function show($id) { $posts = Posts::where('id', '=', $id)->get(); $comments = Comments::where('post_id', '=', $id)->orderBy('created_at', 'desc')->get(); return view('view')->with('posts', $posts)->with('comments', $comments); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index($proId) { $comments = Comments::where('pro_id', $proId)->get(); return response()->json($comments); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($title) { $currentNews = News::where('title_en', $title)->get(); $comments = Comments::where('id', '=', 'comment_id')->get(); return view('CurrentNews', ['currentNews' => $currentNews, 'comments' => $comments]); }
public static function edit($action, array $data, $id) { $goods = self::find($id); if ($action == 'edit') { $rows = Album::where('pid', $id)->get(); $srcNum = Album::where('pid', $id)->count(); $path = 'uploads'; $files = Upload::fileUpload($path); $uploadNum = count($files); if ($uploadNum < $srcNum) { $i = 0; foreach ($files as $file) { $array = ['album_path' => $file['name']]; unlink("uploads/" . $rows[$i]->album_path); $rows[$i]->update($array); $i++; } for ($j = $i; $j < $srcNum; $j++) { $rows[$j]->delete(); unlink("uploads/" . $rows[$j]->album_path); } } elseif ($uploadNum == $srcNum) { $i = 0; foreach ($files as $file) { $updateArr = ['album_path' => $file['name']]; unlink("uploads/" . $rows[$i]->album_path); $rows[$i]->update($updateArr); $i++; } } elseif ($uploadNum > $srcNum) { $i = 0; foreach ($rows as $row) { $updateArr = array('album_path' => $files[$i]['name']); unlink("uploads/" . $row->album_path); $row->update($updateArr); $i++; } for ($j = $i; $j < $uploadNum; $j++) { $insertArr = array('pid' => $id, 'album_path' => $files[$j]['name']); Album::create($insertArr); } } if ($goods->update($data)) { return self::success(['pro_id' => $id]); } return self::fail(); } elseif ($action == 'delete') { if (self::where('id', $id)->delete()) { foreach (Album::where('pid', $id)->get() as $row) { unlink("uploads/" . $row->album_path); } Album::where('pid', $id)->delete(); Comments::where('pro_id', $id)->delete(); return self::success(); } return self::fail(); } }
public function get_doctor_comments(Request $request, $doc_id) { try { $comments = Comments::where('doctor_id', $doc_id)->orderBy('id', 'DESC')->get(); $count = 1; foreach ($comments as $com) { $user = Patients::where('user_id', $com->user_id)->first(); $img = Images::where('user_id', $com->user_id)->first(); $temp['comment'] = $com; $temp['user'] = $user; $temp['user_img'] = $img; $comment_ob['comment_' . $count] = $temp; $count++; } } catch (Exception $e) { $this->LogError('AjaxController Get_Doctor_Comments Function', $e); } if ($count > 1) { $res['COMMENT'] = "YES"; $res['DATA'] = $comment_ob; return response()->json($res); } else { $res['COMMENT'] = "NO"; return response()->json($res); } }
/** * Display the specified resource. * * @return \Illuminate\Http\Response */ public function show($slug) { $post = Posts::where('slug', $slug)->first(); if (!$post) { return redirect('/')->withErrors('requested page not found'); } $comments = Comments::where('on_post', '=', $post->id)->orderBy('created_at', 'desc')->get(); if (Auth::check()) { return view('posts.show')->with(array('currentUser' => Auth::user(), 'post' => $post, 'comments' => $comments)); } else { return view('posts.show')->withPost($post)->withComments($comments); } }