本文整理汇总了PHP中app\Comment::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Comment::where方法的具体用法?PHP Comment::where怎么用?PHP Comment::where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Comment
的用法示例。
在下文中一共展示了Comment::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: post
function post($id)
{
$data['post'] = Post::find($id);
$data['comments'] = Comment::where('post_id', '=', $id)->with('user')->get();
//$data['comments'] = Comment::find($id);
return view('blog/post', $data);
}
示例2: show
/**
* Display the specified resource.
*
* @param $guildSlug
* @param $occurrenceId
* @return \Illuminate\Http\Response
*/
public function show($guildSlug, $occurrenceId)
{
$guild = Guild::where('slug', $guildSlug)->firstOrFail();
$occurrence = EventOccurrence::with(['event', 'event.guild'])->whereHas('event.guild', function ($query) use($guild) {
$query->where('id', $guild->id);
})->findOrFail($occurrenceId);
$event = $occurrence->event;
$guild = $event->guild;
$signups = Signup::where(['event_occurrence_id' => $occurrence->id])->orderBy('created_at')->get();
$comments = Comment::where(['event_occurrence_id' => $occurrence->id])->orderBy('created_at')->get();
$character = Character::whereHas('guilds', function ($query) use($guild) {
$query->where('guilds.id', $guild->id);
})->where(['user_id' => Auth::user()->id])->firstOrFail();
$ownSignup = null;
$isSigned = false;
foreach ($signups as $signup) {
if ($signup->character_id == $character->id) {
$ownSignup = $signup;
$isSigned = true;
}
}
if ($ownSignup == null) {
$ownSignup = new Signup();
}
$statistic = new \stdClass();
foreach (['YES', 'MAYBE', 'NO'] as $status) {
$name = strtolower($status);
$statistic->{$name} = $signups->filter(function ($signup) use($status) {
return $signup->status == $status;
})->count();
}
return view('guilds.events.show', compact('occurrence', 'event', 'guild', 'signups', 'comments', 'ownSignup', 'isSigned', 'statistic'));
}
示例3: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
//
//$comments = DB::table('comments')->where('page_id', $id)->get();
$comments = Comment::where('page_id', $id)->get();
return view('admin.comments.show', ['comments' => $comments]);
}
示例4: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
$task = Task::findOrFail($id);
$comments = Comment::where('tasks_id', '=', $id)->get();
return view('tasks.show', array('task' => $task, 'comments' => $comments));
//
}
示例5: index
public function index(Comment $commentsModel)
{
// $comments = $commentsModel->getPublishedComments();
$comments = Comment::where('active', '=', 1)->where('published_at', '<=', Carbon::now())->latest('published_at')->simplePaginate(4);
$comments->setPath('comments')->currentPage();
return view('comments.comments')->with('comments', $comments);
}
示例6: show
public function show($intelligenceSlug, $tutorialId)
{
$intelligence = Intelligence::where('slug', $intelligenceSlug)->firstOrFail();
$tutorial = Tutorial::where('intelligence_id', $intelligence->id)->findOrFail($tutorialId);
$comments = Comment::where('tutorial_id', $tutorial->id)->paginate(15);
return view('intelligence.tutorial.show', compact('intelligence', 'tutorial', 'comments'));
}
示例7: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index($kdThread)
{
//
$comment = Comment::where('kdThread', '=', $kdThread)->with('threadforum.student', 'threadforum.lecturer', 'student', 'lecturer')->get();
return view('threadforum.comment.index', compact('comment'));
// return $comment->toJson();
}
示例8: show
/**
* Shows the specific user.
* @param string $username
* @return Response
*/
public function show($username)
{
$post_upvotes = 0;
$user = User::where('username', '=', $username)->firstOrFail();
$user_posts = Post::where('user_id', '=', $user->id)->take(3)->get();
foreach ($user_posts as $post) {
$post->username = $user->username;
$post->comment_count = Comment::where('post_id', '=', $post->id)->count();
$post->hub_name = Hub::where('id', '=', $post->hub_id)->firstOrFail()->name;
$post_upvotes = $post_upvotes + (int) $post->upvotes;
$hub = Hub::find($post->hub_id);
if (in_array($post->user_id, explode(',', $hub->moderators))) {
$post->user_is_mod = true;
} else {
$post->user_is_mod = false;
}
$user = User::find($post->user_id);
if ($user->is_admin) {
$post->user_is_admin = true;
} else {
$post->user_is_admin = false;
}
}
$comment_upvotes = 0;
$user_comments = Comment::where('user_id', '=', $user->id)->take(3)->get();
foreach ($user_comments as $comment) {
$comment_upvotes = $comment_upvotes + (int) $comment->upvotes;
$comment->email = md5($user->email);
}
return view('user.show', ['user' => $user, 'email' => md5($user->email), 'post_upvotes' => $post_upvotes, 'comment_upvotes' => $comment_upvotes, 'comments' => $user_comments, 'posts' => $user_posts]);
}
示例9: showProfile
/**
* Show the application dashboard to the user.
*
* @return Response
*/
public function showProfile($id)
{
$user = User::find($id);
$posts = Post::where("user_id", $id)->get();
$comments = Comment::where('user_id', $id)->get();
return view('user.profile', ['user' => $user, 'comments' => $comments, 'posts' => $posts]);
}
示例10: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
$adventure = Adventure::find($id);
$comments = Comment::where('adventure_id', $id)->get();
$pictures = Picture::where('adventure_id', $id)->get();
return view('adventures.show', compact('adventure', 'comments'))->with('pictures', $pictures);
}
示例11: showpost
public function showpost($id)
{
//display one post
$article = Article::findOrFail($id);
$comment = Comment::where('postid', '=', $id)->get();
//if (is_null($article)) { abort(404); }
return view('articles.show', compact('article', 'comment'));
}
示例12: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$pre_page = 6;
$comments = Comment::where('status', '<>', 2)->paginate($pre_page);
//return view('admin/article/index');
$comments->setPath('comment');
return view('admin/comment/index')->with('comments', $comments);
}
示例13: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $commentid
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $commentid)
{
$reply = new \App\Reply();
$reply->create(['user_id' => \Auth::user()->id, 'comment_id' => $request['comment_id'], 'comment' => $request['comment']]);
$comment = \App\Comment::where(['id' => $commentid])->get()->first();
$comment->reply = $reply;
return redirect()->back();
}
示例14: getByAdId
public static function getByAdId($id)
{
$comments = Comment::where(['ad_id' => $id, 'answer_to' => null])->join('users', 'comments.author_id', '=', 'users.id')->select(['comments.*', 'users.name as author_name'])->orderBy('comments.created_at')->get();
foreach ($comments as $comment) {
$comment->answers = Comment::where('answer_to', $comment->id)->join('users', 'comments.author_id', '=', 'users.id')->select(['comments.*', 'users.name as author_name'])->get();
}
return $comments;
}
示例15: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
$course = Course::where('id', $id)->orWhere('slug', $id)->firstOrFail();
$data = Data::where('courseId', $course->id)->where('extension', '!=', 'mp4')->accepted()->get();
$videos = Data::where('courseId', $course->id)->Where('extension', 'mp4')->accepted()->get();
$comments = Comment::where('courseId', $course->id)->get();
return view('courses.show', compact('course', 'comments', 'data', 'videos'));
}