public function get($id) { $enemy = Enemy::with('episodes')->find($id); $ratings = Rating::getRating('enemy', $id); $comments = Comment::where('item_id', $id)->where('item_type', 'enemy')->with('user')->orderBy('created_at', 'desc')->get(); return View::make('items.enemy', ['enemy' => $enemy, 'ratings' => $ratings, 'comments' => $comments]); }
public function get($season, $episode) { $episode = Episode::with(['doctors', 'companions', 'enemies'])->where('season', $season)->where('episode', $episode)->first(); $ratings = Rating::getRating('episode', $episode->id); $comments = Comment::where('item_id', $episode->id)->where('item_type', 'episode')->with('user')->orderBy('created_at', 'desc')->get(); return View::make('items.episode', ['episode' => $episode, 'ratings' => $ratings, 'comments' => $comments]); }
public function getArticle($id) { $post = Post::find($id); $sidePosts = Post::take(3)->offset(1)->orderby('id', 'desc')->get(); $comments = Comment::where('post_id', $id)->get(); return View::make('pages.view')->with(compact('post', 'sidePosts', 'comments'))->with('pageTitle', $post->title); }
public function get($id) { $doctor = Doctor::with(['companions', 'episodes'])->find($id); $ratings = Rating::getRating('doctor', $id); $comments = Comment::where('item_id', $id)->where('item_type', 'doctor')->with('user')->orderBy('created_at', 'desc')->get(); return View::make('items.doctor', ['doctor' => $doctor, 'ratings' => $ratings, 'comments' => $comments]); }
public function showIndex() { if (!Auth::check()) { return View::make('login', array('title' => 'edison')); } $category_names = array('ent' => 'エンターテイメント', 'music' => '音楽', 'sing' => '歌ってみた', 'play' => '演奏してみた', 'dance' => '踊ってみた', 'vocaloid' => 'VOCALOID', 'nicoindies' => 'ニコニコインディーズ', 'animal' => '動物', 'cooking' => '料理', 'nature' => '自然', 'travel' => '旅行', 'sport' => 'スポーツ', 'lecture' => 'ニコニコ動画講座', 'drive' => '車載動画', 'history' => '歴史', 'politics' => '政治', 'science' => '科学', 'tech' => 'ニコニコ技術部', 'handcraft' => 'ニコニコ手芸部', 'make' => '作ってみた', 'anime' => 'アニメ', 'game' => 'ゲーム', 'toho' => '東方', 'imas' => 'アイドルマスター', 'radio' => 'ラジオ', 'draw' => '描いてみた', 'are' => '例のアレ', 'diary' => '日記', 'other' => 'その他', 'r18' => 'R-18', 'original' => 'オリジナル', 'portrait' => '似顔絵', 'character' => 'キャラクター'); $all_items = Item::orderBy('created_at', 'desc')->take(10)->get(); foreach ($all_items as &$item) { $item['user'] = User::where('id', '=', $item->user_id)->get()[0]; $item['star_count'] = Starmap::where('item_id', '=', $item->id)->count(); $item['comment_count'] = Comment::where('item_id', '=', $item->id)->count(); if ($item->category_id != 0) { $item['category'] = Category::where('id', '=', $item->category_id)->get()[0]->content; } } $recent_works = Work::orderBy('created_at', 'desc')->take(10)->get(); foreach ($recent_works as &$work) { $item = Item::where('id', '=', $work->item_id)->get()[0]; $work['item'] = $item; $work['user'] = User::where('id', '=', $work->user_id)->get()[0]; $work['item_poster_screen_name'] = User::where('id', '=', $item->user_id)->get()[0]->screen_name; if ($item->category_id != 0) { $work['item_category'] = Category::where('id', '=', $item->category_id)->get()[0]->content; } } $user = User::where('screen_name', '=', Auth::user()->screen_name)->get()[0]; $data = array('title' => 'edison', 'user' => $user, 'all_items' => $all_items, 'recent_works' => $recent_works, 'categories' => $category_names, 'star_count' => Starmap::where('user_id', '=', $user->id)->count(), 'work_count' => Work::where('user_id', '=', Auth::user()->id)->count()); return View::make('index', $data); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $input = Input::all(); $validation = Validator::make($input, Comment::$rules); if ($validation->passes()) { $last_comment = Comment::where('user_id', '=', Auth::user()->id)->orderBy('created_at', 'desc')->first(); $current_date = new DateTime(date("Y-m-d H:i:s")); if (empty($last_comment)) { $interval = 5; } else { $interval = $current_date->diff($last_comment->created_at); $interval = intval($interval->format('%i')); } if ($interval >= 3) { $this->add_daily_comment_points(); $comment = new Comment(); $comment->media_id = $input['media_id']; $comment->comment = htmlspecialchars($input['comment']); $comment->user_id = Auth::user()->id; $comment->save(); echo $comment; } else { echo 0; } } else { echo 0; } }
public function delete1($id) { $regno = Comment::where('id', $id)->first(); $data = $regno->email; // return $data; Comment::destroy($id); return Redirect::to('mail')->with('deleted', $data . ' is successFull Deleted from Database'); }
public function updateComment(Comment $comment) { $comment->approved = Input::get('status'); $comment->save(); $comment->post->comment_count = Comment::where('post_id', '=', $comment->post->id)->where('approved', '=', 1)->count(); $comment->post->save(); return Redirect::back()->with('success', 'Comment ' . ($comment->approved === 'yes' ? 'Approved' : 'Disapproved')); }
public function updateComment(Comment $comment) { $comment->approved = Input::get('status'); $comment->save(); $comment->post->comment_count = Comment::where('post_id', '=', $comment->post->id)->where('approved', '=', 1)->count(); $comment->post->save(); return Redirect::back()->withMessage('Commentaire ' . ($comment->approved === 'yes' ? 'approuvé' : 'refusé')); }
/** * Execute the console command. * * @return mixed */ public function fire() { $doc_id = $this->argument('doc_id'); $filename = $this->argument('filename'); $doc = Doc::where('id', $doc_id)->first(); $this->info("Exporting activity for " . $doc->title); $annotations = Annotation::where('doc_id', $this->argument('doc_id'))->with('user')->with('comments')->get(); $comments = Comment::where('doc_id', $this->argument('doc_id'))->with('user')->get(); $headers = array("Created At", "Link", "Display Name", "Full Name", "Email", "Type", "Quote", "Text"); $toExport = array(); foreach ($annotations as $annotation) { $annotationArray = array(); $annotationArray['date'] = $annotation->created_at; $annotationArray['link'] = URL::to('/') . $annotation->uri . '#annotation_' . $annotation->id; $annotationArray['display_name'] = $annotation->user->fname . " " . substr($annotation->user->lname, 0, 1); $annotationArray['full_name'] = $annotation->user->fname . " " . $annotation->user->lname; $annotationArray['email'] = $annotation->user->email; $annotationArray['type'] = 'Annotation'; $annotationArray['quote'] = $annotation->quote; $annotationArray['text'] = $annotation->text; array_push($toExport, $annotationArray); foreach ($annotation->comments as $comment) { $user = User::find($comment->user_id); $commentArray = array(); $commentArray['date'] = $comment->created_at; $commentArray['link'] = ""; $commentArray['display_name'] = $user->fname . " " . substr($user->lname, 0, 1); $commentArray['full_name'] = $user->fname . " " . $user->lname; $commentArray['email'] = $user->email; $commentArray['type'] = "Annotation Comment"; $commentArray['quote'] = ""; $commentArray['text'] = $comment->text; array_push($toExport, $commentArray); } } foreach ($comments as $comment) { $commentArray = array(); $commentArray['date'] = $comment->created_at; $commentArray['link'] = ""; $commentArray['display_name'] = $comment->user->fname . " " . substr($comment->user->lname, 0, 1); $commentArray['full_name'] = $comment->user->fname . " " . $comment->user->lname; $commentArray['email'] = $comment->user->email; $commentArray['type'] = $comment->parent_id === null ? "Comment" : "Sub-comment"; $commentArray['quote'] = ""; $commentArray['text'] = $comment->text; array_push($toExport, $commentArray); } $this->info('Saving export to ' . $filename); $fp = fopen($filename, 'w'); fputcsv($fp, $headers); foreach ($toExport as $row) { fputcsv($fp, $row); } fclose($fp); $this->info('Done.'); }
/** * Display customer profile * * @param $profile * @return Response */ public function show($profile) { $p = User::where('profile_url', '=', $profile)->where('approved', '=', '0')->first(); $page = Page::where('title', '=', 'faq-customer')->first(); $follow = Follow::where('user', $p->id)->where('hub', '=', 0)->get(); $follow_hub = Follow::where('user', $p->id)->where('artist', '=', 0)->get(); $wall = new \Illuminate\Database\Eloquent\Collection(); $events = new \Illuminate\Database\Eloquent\Collection(); $comments = Comment::where('user', '=', $p->id)->orderBy('created_at', 'desc')->get(); $hidden = unserialize(Cookie::get('hide')); //dd( Cookie::get('hide') ); if (count($follow) > 0) { foreach ($follow as $f) { $s = Song::where('artist', '=', $f->artist)->where('completed', '=', '1')->get(); $e = ArtistEvent::where('artist', '=', $f->artist)->where('date', '>', \Carbon\Carbon::now())->get(); $wall = $wall->merge($s); $events = $events->merge($e); } } if (count($follow_hub) > 0) { foreach ($follow_hub as $h) { $hub = Hub::where('id', '=', $h->hub)->first(); if (!is_null($hub)) { $artists = User::where('type', '=', 'artist')->where('hub', '=', $hub->id)->get(); $artists_list = []; $songs = []; $events = []; foreach ($artists as $a) { $artists_list[] = $a->id; } if (count($artists_list) > 0) { $songs = Song::where('completed', '=', '1')->whereIn('artist', $artists_list)->orderBy('created_at', 'desc')->get(); $events = ArtistEvent::whereIn('artist', $artists_list)->get(); } $news = News::where('hub', '=', $hub->id)->take(3)->get(); $wall = $wall->merge($songs); $events = $events->merge($events); } } } $purchased = Purchase::where('customer', '=', $p->id)->get(); foreach ($purchased as $pp) { $song_purchased = Song::withTrashed()->where('id', '=', $pp->song)->get(); $download = Download::where('customer', '=', $p->id)->where('song', '=', $pp->song)->first(); $song_purchased[0]->purchased = true; if (isset($download)) { $song_purchased[0]->link = $download->url; } $wall = $wall->merge($song_purchased); } $wall->sortByDesc('created_at'); if (!isset($news)) { $news = null; } return View::make('customer.profile-new', ['profile' => $p, 'wall' => $wall, 'page' => $page, 'events' => $events, 'comments' => $comments, 'hidden' => $hidden, 'news' => $news]); }
function my_article_has_comments() { if (!($itm = Registry::get('article'))) { return false; } $comments = Comment::where('status', '=', 'approved')->where('post', '=', $itm->id)->get(); $comments = new Items($comments); Registry::set('my_article_comments', $comments); return $comments->length(); }
public function viewDetails($id) { $photo = Photo::find($id); if ($photo === null) { $error = 'No such photo found.'; return View::make('errors.error', array('errorMsg' => $error)); } $comments = Comment::where('photo_id', '=', $photo->id)->with('author')->get(); return View::make('photo.details', array('photo' => $photo, 'comments' => $comments)); }
/** * Override delete method * Delete topic itself and all it's comments, ratings, and view counter */ public function delete() { $tid = $this->id; // delete view counter Counter::where("[entityId] = ? AND [entityTypeId] = ?", [$tid, Topic::ENTITY_TYPE])->delete(); Rating::where("[entityId] = ? AND [entityType] = ?", [$tid, Topic::ENTITY_TYPE])->delete(); RatingStatistic::where("[entityId] = ? AND [entityType] = ?", [$tid, Topic::ENTITY_TYPE])->delete(); Comment::where("[topicId] = ?", $tid)->delete(); parent::delete(); }
public function show($conversation) { $user = Confide::user(); $comments = Comment::where('conversation_id', '=', $conversation->id)->orderBy('created_at', 'asc')->get(); $conversation->sender = User::find($conversation->sender); $conversation->receiver = User::find($conversation->receiver); foreach ($comments as $comment) { $comment->user = User::find($comment->user_id); } return View::make('home/conversation/show', compact('user', 'conversation', 'comments')); }
public function getNewsComments($id) { try { $this->googleAnalytics('/comments/news-comments/' . $id); $news = News::findOrFail($id); $comments = Comment::where('news_id', $id)->where('published', 1)->orderBy('created_at', 'desc')->paginate(20); return Response::json($comments); } catch (Exception $e) { return Response::json(array('status' => 'fail')); } }
static function getAllComments(&$message, $search = null) { if (!is_null($search)) { $message = "Showing all comments searches by \"{$search}\""; echo "%{$search}%"; return Comment::where('name', 'like', "%{$search}%")->or_where('content', 'like', "%{$search}%")->or_where('email', 'like', "%{$search}%")->order_by('id', 'desc'); } else { $message = "Showing all comments"; return Comment::order_by('id', 'desc'); } }
public function book($id) { /*$like = Like::where('idkatalog','=',Input::get('id')) ->where('iduser','=',Auth::user()->id) ->get(); $cek = json_encode(array('exists'=>count($like)));*/ $book = DB::table('katalog')->leftjoin('publisher', 'katalog.publisher', '=', 'publisher.id')->where('katalog.id', '=', $id)->get(array('katalog.id', 'katalog.title', 'katalog.summary', 'katalog.release', 'katalog.numpage', 'katalog.ISBN', 'publisher.publishername', 'katalog.img', 'katalog.category', 'katalog.like')); //var_dump($book); $authors = AuthorKatalog::get_author_katalog($id); $comment = Comment::where('id_obj', '=', $book[0]->id)->where('cat_comment', '=', 1)->get(); return View::make('front.book', compact('book', 'authors', 'comment')); }
public static function updated(User $user) { if (!$user->is_anonymous()) { $query = Comment::where("user_id <> ?", $user->id); } else { $query = Comment::none(); } if (!($newest_comment = $query->order("id desc")->limit(1)->select("created_at")->first())) { return false; } !$user->last_comment_read_at && ($user->last_comment_read_at = '0000-00-00 00:00:00'); return $newest_comment->created_at > $user->last_comment_read_at; }
public function backendPrepare() { $commentCount = Comment::where('published', '=', 0)->where('created_at', '>', date('Y-m-d H:i:s', strtotime('-30 days')))->count(); $unpublishedComments = Comment::where('published', '=', 0)->where('created_at', '>', date('Y-m-d H:i:s', strtotime('-30 days')))->orderBy('created_at', 'desc')->take(10)->get(); try { $admin = User::findOrFail(Session::get('id')); View::share('admin', $admin); } catch (Exception $e) { return Redirect::to('login')->with('message', Lang::get('login.error'))->with('notif', 'danger'); } View::share('commentCount', $commentCount); View::share('unpublishedComments', $unpublishedComments); }
public function getStars($screen_name) { $user = User::where('screen_name', '=', $screen_name)->first(); $star_lists = Starmap::where('user_id', '=', $user->id)->orderby('created_at', 'desc')->take(10)->get(); $star_items = array(); foreach ($star_lists as &$star_list) { $star_list['item'] = Item::where('id', '=', $star_list->item_id)->get()[0]; $star_list['item']['user'] = User::where('id', '=', $star_list->item->user_id)->get()[0]; $star_list['item']['star_count'] = Starmap::where('id', '=', $star_list->item_id)->count(); $star_list['item']['comment_count'] = Comment::where('id', '=', $star_list->item_id)->count(); $star_list['category_name'] = Category::where('id', '=', $star_list->item->category_id)->first()->content; } return $star_lists; }
public static function boot() { parent::boot(); // cause a delete of a category to cascade to children so they are also deleted static::deleted(function ($category) { $posts = BlogPost::where('category_id', '=', $category->id)->get(); if (!empty($posts)) { foreach ($posts as $post) { $comments = Comment::where('on_post', '=', $post->id); $comments->delete(); } $category->posts()->delete(); } }); }
public function viewPhotos($id) { $album = Album::find($id); if ($album === null) { $error = 'Invalid album.'; return View::make('errors.error', array('errorMsg' => $error)); } if (Auth::user()) { $isVoted = sizeof(Vote::where('album_id', '=', $album->id)->where('voter_id', '=', Auth::user()->id)->get()) !== 0; # code... } else { $isVoted = true; } $comments = Comment::where('album_id', '=', $album->id)->with('author')->get(); return View::make('albums.viewPhotos', array('photos' => $album->photos()->get(), 'comments' => $comments, 'albumId' => $album->id, 'isVoted' => $isVoted)); }
public function getUnpublished() { if (Session::get('user_level') < Config::get('cms.viewComments')) { return Redirect::to(_l(URL::action('AdminHomeController@getIndex')))->with('message', Lang::get('admin.notPermitted'))->with('notif', 'warning'); } $this->setLayout(); if (Input::get('q')) { $comments = Comment::where('published', '=', 0)->where('comment_content', 'LIKE', '%' . Input::get('q') . '%')->orderBy('created_at', 'desc')->paginate(20); } else { $comments = Comment::where('published', '=', 0)->orderBy('created_at', 'desc')->paginate(20); } View::share('title', __(Lang::get('admin.comments'))); View::share('comments', $comments); View::share('redirect', 'unpublished'); $this->layout->content = View::make('backend.comments.index'); }
public function getIndex() { $id = Auth::id(); $posts = Post::where("author_id", $id)->get(); foreach ($posts as $post) { $user = $post->user; $post["username"] = $user["username"]; $format = "F j, Y, g:i a"; $date = new DateTime($post['updated_at']); $formatDate = $date->format($format); $post["updated_time"] = $formatDate; $comments = Comment::where('post_id', $post["_id"])->count(); $post["commentCount"] = $comments; } //print_r($posts[2]); return View::make('backend.post', array('posts' => $posts)); }
public static function getCommentsOfPost($post_id) { $comments = Comment::where('post_id', $post_id)->get(); foreach ($comments as $comment) { $user_id = $comment['user_id']; $user = User::getUserById($user_id); $comment['username'] = $user['username']; $comment['avatar_link'] = $user['avatar_link']; $comment['email'] = $user['email']; $post = Post::getPostById($comment["post_id"]); $comment['title'] = $post['title']; $format = "F j, Y, g:i a"; $date = new DateTime($post['updated_at']); $formatDate = $date->format($format); $comment['update_time'] = $formatDate; } return $comments; }
function index($name) { $a = new Account(); if ($name != "") { $c = new Campaign(); $c->where('nickname', $name)->get(); if ($c->id > 0) { $data['campaign_id'] = $c->id; $data['name'] = $c->name; $data['description'] = $c->description; $data['photo'] = $c->photo; $data['countryid'] = $c->countryid; $data['categoryid'] = $c->categoryid; $data['isInfo'] = $c->isInfo; $data['title'] = $c->name; /* * get comments for the campaign */ $com = new Comment(); $com->where('campaign_id', $c->id)->get(); //$comments = new ArrayObject(); $commentsStr = "["; $flag = 0; foreach ($com->all as $comment) { $usr = new Account(); $usr->where('id', $comment->user_id)->get(); $preCom = "<img src = '" . base_url() . "/images/profile/" . $usr->photo . "' align='left'><i>says </i>"; if ($flag) { $commentsStr = $commentsStr . ","; } $flag = 1; $commentsStr = $commentsStr . "\"" . $preCom . $comment->comment . "\""; //$data['comments'][] = $comment->comment; //$data['comments_uid'][] = $comment->user_id; } $commentsStr = $commentsStr . "]"; $data['commentsStr'] = $commentsStr; $data['commentsNum'] = $com->count(); } } $data['a'] = $a; $_SESSION['url'] = site_url('destination/index/' . $name); $this->load->view('destination', $data); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $input = Input::all(); $validation = Validator::make($input, Comment::$rules); if ($validation->passes()) { $last_comment = Comment::where('user_id', '=', Auth::user()->id)->orderBy('created_at', 'desc')->first(); $current_date = new DateTime(date("Y-m-d H:i:s")); if (empty($last_comment)) { $interval = 5; } else { $interval = $current_date->diff($last_comment->created_at); $interval = intval($interval->format('%i')); } /*if($interval >= 3){*/ $this->add_daily_comment_points(); $comment = new Comment(); $comment->media_id = $input['media_id']; $comment->comment = htmlspecialchars($input['comment']); $comment->user_id = Auth::user()->id; //echo $comment; if ($comment->save()) { $notification = new Notification(); $media = Media::find($comment->media_id); $notification->user_id = $media->user_id; $user_comment = $comment->user()->username; $notification->url_comment = URL::to('media') . '/' . $media->slug; if ($media->user_id == Auth::user()->id) { $notification->is_read = 1; } else { $notification->is_read = 0; $notification->content = $user_comment . " comments in " . '" ' . $comment->media()->title . ' " your'; } $notification->save(); } echo $comment; /*} else { echo 0; }*/ } else { echo 0; } }
/** * 更新请求 * * @param Request $request * @param int $id * @return void */ public function update(Request $request, $id) { // 验证 $this->validate($request, ['topic' => 'string', 'participants' => 'string', 'state' => 'required|in:1,-1', 'reply_message' => 'required|string']); $log = Comment::find($id); // 更新 DB::transaction(function () use($request, $log) { if (Comment::STATUS['ENABLE'] == $request->state) { // 参与人 $participantIds = []; $participantNames = Participant::filterParticipantNames($request->participants); if (!empty($participantNames)) { foreach ($participantNames as $name) { $participant = Participant::firstOrCreate(['name' => $name]); $participant->increment('counts', 1); $participantIds[] = $participant->id; } } // 节目 $program = Program::where('date', date('Y-m-d', strtotime($log->metas->thread_key)))->first(); $topic = Program::filterTopic($request->topic); if (!empty($topic)) { $program->update(['topic' => $topic]); } if (!empty($participantIds)) { $program->participants()->sync($participantIds); } } // 刷新首页文件缓存 Cache::forget(Program::INDEX_CACHE_KEY); // 刷新贡献记录页文件缓存 Cache::forget(Comment::CONTRIBUTION_CACHE_KEY); // 记录日志 Comment::where('id', $log->id)->update(['ext_is_agree' => $request->state]); }); // 回复评论 $state = Comment::replyPost($request->reply_message, $log->metas->thread_id, $log->metas->post_id, $log->metas->author_email); // 跳转 $status = ['status' => $state ? 'success' : 'error', 'message' => $state ? '审核成功~' : '审核成功,回复失败']; return Redirect::to($request->_redirect_url)->with($status['status'], $status['message']); }
/** * Show track page with comments * * @param $id * @return Response */ public function track($id) { $song = Song::find($id); if ($song) { $user = $song->artist; $comments = Comment::where('song', '=', $song->id)->orderBy('id', 'desc')->get(); $profile = User::find($user); $songs = Song::where('artist', '=', $profile->id)->where('completed', '=', '1')->orderBy('id', 'desc')->get(); $activation = Activation::where('user', '=', $profile->id)->first(); $followers = Follow::where('artist', '=', $profile->id)->get(); $countries = []; foreach ($followers as $f) { if (empty($f->profile->country)) { $f->profile->country = 'Country unknown'; } if (isset($countries[$f->profile->country])) { $countries[$f->profile->country]++; } else { $countries[$f->profile->country] = 1; } } if ($activation) { return View::make('artist.not-activated'); } else { if ($profile) { $events = ArtistEvent::where('artist', '=', $profile->id)->where('date', '>', \Carbon\Carbon::now())->orderBy('id', 'desc')->take(3)->get(); $songs_in = []; $songs = Song::where('artist', '=', $profile->id)->where('completed', '=', '1')->get(); foreach ($songs as $s) { $songs_in[] = $s->id; } $comments_block = Comment::whereIn('song', $songs_in)->orderBy('id', 'desc')->take(3)->get(); return View::make('artist.track-new', ['profile' => $profile, 'song' => $song, 'comments' => $comments_block, 'comments_this' => $comments, 'events' => $events, 'songs' => $songs, 'countries' => $countries]); } else { App::abort(404); } } } else { App::abort('404'); } }