本文整理汇总了PHP中Comment::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Comment::where方法的具体用法?PHP Comment::where怎么用?PHP Comment::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Comment
的用法示例。
在下文中一共展示了Comment::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
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]);
}
示例2: get
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]);
}
示例3: getArticle
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);
}
示例4: get
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]);
}
示例5: showIndex
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);
}
示例6: store
/**
* 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;
}
}
示例7: delete1
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');
}
示例8: updateComment
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'));
}
示例9: updateComment
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é'));
}
示例10: fire
/**
* 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.');
}
示例11: show
/**
* 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]);
}
示例12: my_article_has_comments
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();
}
示例13: viewDetails
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));
}
示例14: delete
/**
* 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();
}
示例15: show
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'));
}