当前位置: 首页>>代码示例>>PHP>>正文


PHP Posts::where方法代码示例

本文整理汇总了PHP中app\Posts::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Posts::where方法的具体用法?PHP Posts::where怎么用?PHP Posts::where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Posts的用法示例。


在下文中一共展示了Posts::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: userPosts

 public function userPosts()
 {
     $posts = \App\Posts::where('user_id', '=', \Auth::user()->id)->orderBy("created_at", "desc")->get();
     $search_info = "";
     $data = array('posts' => $posts, 'search_info' => \Auth::user()->name . '\'s posts', 'users' => \App\User::get());
     return view('home')->with($data);
 }
开发者ID:steakyfask,项目名称:ShareStuff,代码行数:7,代码来源:HomeController.php

示例2: user_posts_draft

 public function user_posts_draft(Request $request)
 {
     $user = $request->user();
     $posts = Posts::where('author_id', $user->id)->where('active', '0')->orderBy('created_at', 'desc')->paginate(5);
     $title = $user->name;
     return view('home')->withPosts($posts)->withTitle($title);
 }
开发者ID:Kristian95,项目名称:LaravelBlog,代码行数:7,代码来源:UserController.php

示例3: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show(Request $request, $slug)
 {
     $category = Categories::where('slug', $slug)->first();
     $posts = Posts::where('category_id', $category->id)->orderBy('created_at', 'desc')->paginate(5);
     $title = 'Posts from category ' . $category->title;
     return view('categories.show')->withPosts($posts)->withCategory($category)->withTitle($title);
 }
开发者ID:calimanleontin,项目名称:bet,代码行数:13,代码来源:CategoryController.php

示例4: idoso

 public function idoso()
 {
     $posts = \App\Posts::where('tipo', '=', 'postagem')->where('categoria_id', '!=', 7)->latest()->take(8)->get();
     $numero = 4;
     $programas = \App\Posts::where('tipo', '=', 'programas')->orderBy('id', 'desc')->take(6)->where('grupo_id', '=', $numero)->get();
     // dd($posts);
     return view('persona4', compact('posts', 'numero', 'programas'));
 }
开发者ID:ronal2do,项目名称:stq001,代码行数:8,代码来源:PagesController.php

示例5: show

 public function show($slug)
 {
     $post = Posts::where('slug', $slug)->first();
     if (!$post) {
         return redirect('/')->withErrors('Page not found');
     }
     $comments = $post->comments;
     return view('posts.show')->withPost($post)->withComments($comments);
 }
开发者ID:Kristian95,项目名称:LaravelBlog,代码行数:9,代码来源:PostController.php

示例6: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $allUserPosts = Posts::where('user_id', \Auth::user()->id)->orderBy('created_at', 'DESC')->get();
     // $UAI = UserAdditionalInfo::findOrFail($UAI_id);
     // $userInfo = UserAdditionalInfo::where('user_id', \Auth::user()->id)->first();
     $userInfo = \Auth::user();
     $allEvents = Events::orderBy('created_at', 'DESC')->take(2)->get();
     $allUserPhotos = PhotoMapImageUploader::where('userId', \Auth::user()->id)->orderBy('photoMapId', 'DESC')->take(6)->get();
     return view('profilePage.index', compact('allUserPosts', 'userInfo', 'allEvents', 'allUserPhotos'));
 }
开发者ID:np-patel,项目名称:exploreTasman,代码行数:15,代码来源:ProfilePageController.php

示例7: managePost

 public function managePost()
 {
     $user_id = Auth::user()->id;
     if ($user_id == 1) {
         $arrPost = Posts::all();
     } else {
         $arrPost = Posts::where('user_id', '=', $user_id)->get();
     }
     return view('pages.managePost', array('arrPost' => $arrPost));
 }
开发者ID:keshavkatwe,项目名称:advsystem,代码行数:10,代码来源:Post.php

示例8: showpdf

 public function showpdf($slug)
 {
     $artikel = \App\Posts::where('slug', $slug)->first();
     if (!empty($artikel)) {
         $data = array('data' => $artikel);
         $pdf = \PDF::loadview('artikel.pdf', $data);
         return $pdf->stream($slug . 'pdf');
     } else {
         return redirect(url());
     }
 }
开发者ID:AsepSanjay,项目名称:blog,代码行数:11,代码来源:WelcomeController.php

示例9: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $xml = simplexml_load_file('http://www.buzzfeed.com/index.xml', 'SimpleXMLElement', LIBXML_NOCDATA);
     $count = 0;
     foreach ($xml->channel->item as $article) {
         $title = $article->title;
         $url = $article->link;
         $author = $article->author;
         $start = strpos($article->pubDate, ',');
         $date = substr($article->pubDate, $start + 2, -15);
         $date = explode(' ', $date);
         $day = $date[0];
         //day
         $month = $date[1];
         //month
         $month = substr(Carbon::parse($month), 5, 2);
         $year = $date[2];
         //year
         $date = substr(Carbon::createFromFormat("Y-m-d", $year . "-" . $month . "-" . $day), 0, 10);
         $description = $article->description;
         $imgPos = strpos($description, '<img');
         $imgUrl = null;
         if ($imgPos != null) {
             $imgString = substr($description, $imgPos);
             $srcPos = strpos($imgString, 'src=');
             $src = substr($imgString, $srcPos + 5);
             $tok = '"';
             $endQuotePos = strpos($src, $tok);
             $imgUrl = substr($src, 0, $endQuotePos);
         }
         $id = DB::table('email_articles')->where('post_date', $date)->value('article_id');
         if ($count < 5) {
             if (!isset($imgUrl)) {
             } else {
                 if (Posts::where('title', '=', $title)->exists()) {
                     echo $title . " already exists";
                 } else {
                     $post = new Posts();
                     $post->article_id = $id;
                     $post->author = $author;
                     $post->title = $title;
                     $post->description = 'N/A';
                     $post->imgUrl = $imgUrl;
                     $post->url = $url;
                     $post->source = 'BuzzFeed';
                     $post->save();
                     echo "stored " . $title . "!";
                 }
                 $count++;
             }
         }
     }
 }
开发者ID:kcunanan,项目名称:claremontrise,代码行数:58,代码来源:GetBuzzFeed.php

示例10: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     //  pokazhi post so soodvetniot id, zaedno so site negovi komentari
     $post = Posts::where('id', $id)->first();
     if (!$post) {
         // ne postoi toj post, vrakja 500 error
     }
     $comments = $post->comments;
     $likes = $post->likes;
     return response()->json($post, 200);
     // ->setCallback($request->input('callback'));
     // return view('posts.show')->withPost($post)->withComments($comments);
 }
开发者ID:DenicijaStojanovska,项目名称:pet-care,代码行数:19,代码来源:PostController.php

示例11: show

 public function show($slug)
 {
     $post = Posts::where('slug', $slug)->first();
     if ($post) {
         if ($post->active == false) {
             return redirect('/');
         }
         $comments = $post->comments;
     } else {
         return redirect('/');
     }
     return view('posts.show')->withPost($post)->withComments($comments);
 }
开发者ID:anmolarora,项目名称:MyBlog_PHP,代码行数:13,代码来源:PostController.php

示例12: dashboard

 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'));
 }
开发者ID:ehumps,项目名称:whiteboard,代码行数:42,代码来源:PagesController.php

示例13: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request)
 {
     //
     $post_id = $request->input('post_id');
     $post = Posts::find($post_id);
     if ($post && ($post->author_id == $request->user()->id || $request->user()->is_admin())) {
         $title = $request->input('title');
         $subtitle = $request->input('subtitle');
         $slug = str_slug($title);
         $duplicate = Posts::where('slug', $slug)->first();
         if ($duplicate) {
             if ($duplicate->id != $post_id) {
                 return redirect('edit/' . $post->slug)->withErrors('Title already exists.')->withInput();
             } else {
                 $post->slug = $slug;
             }
         }
         $post->title = $title;
         $post->subtitle = $subtitle;
         $post->body = $request->input('body');
         if ($request->has('save')) {
             $post->active = 0;
             $message = 'Post saved successfully';
             $landing = 'edit/' . $post->slug;
         } else {
             $post->active = 1;
             $message = 'Post updated successfully';
             $landing = $post->slug;
         }
         $post->save();
         return redirect($landing)->withMessage($message);
     } else {
         return redirect('/')->withErrors('you have not sufficient permissions');
     }
 }
开发者ID:skakoty,项目名称:JEC-Feedback-Management-System,代码行数:41,代码来源:PostController.php

示例14: viewPost

 public function viewPost($postID)
 {
     if (!auth() || !auth()->user()) {
         $browser = get_browser(null, true);
         // Allow crawler && Facebook Bot view post without logging in.
         if ($browser['crawler'] != 1 && stripos($_SERVER["HTTP_USER_AGENT"], 'facebook') === false && stripos($_SERVER["HTTP_USER_AGENT"], 'face') === false && stripos($_SERVER["HTTP_USER_AGENT"], 'google') === false) {
             $redirectPath = '/post/' . $postID;
             return redirect('/login')->with('redirectPath', $redirectPath);
         }
         $token = md5(rand(), false);
         $DisplayedQuestions = ConstsAndFuncs::$FreeQuestionsForCrawler;
     }
     $post = Posts::find($postID);
     if (count($post) < 1) {
         return view('errors.404');
     }
     $courseID = $post['CourseID'];
     $course = Courses::find($courseID);
     $post->visited++;
     $post->update();
     $post = $post->toArray();
     if (auth() && auth()->user()) {
         $userID = auth()->user()->getAuthIdentifier();
         if (User::find($userID)['admin'] < ConstsAndFuncs::PERM_ADMIN) {
             if ($course['Hidden'] == 1 || $post['Hidden'] == 1) {
                 return view('errors.404');
             }
         }
         $tmp = Learnings::where('UserID', '=', $userID)->where('CourseID', '=', $courseID)->get()->toArray();
         if (count($tmp) < 1) {
             $learnings = new Learnings();
             $learnings->UserID = $userID;
             $learnings->CourseID = $courseID;
             $learnings->save();
             $course->NoOfUsers++;
             $course->update();
         }
         // Insert a new record into DoExams Table to mark the time user start answering questions in post.
         $exam = new Doexams();
         $exam->UserID = $userID;
         $exam->PostID = $postID;
         $token = md5($userID . rand(), false) . md5($postID . rand(), false);
         $exam->token = $token;
         $exam->save();
         // Check if user is vip or not
         $user = User::find(auth()->user()->getAuthIdentifier());
         if ($user['vip'] == 0) {
             $DisplayedQuestions = $post['NoOfFreeQuestions'];
         } else {
             $DisplayedQuestions = new \DateTime($user['expire_at']) >= new \DateTime() ? -1 : $post['NoOfFreeQuestions'];
         }
         if ($user['admin'] >= ConstsAndFuncs::PERM_ADMIN) {
             $DisplayedQuestions = -1;
         }
         // If web hasn't provide some VIP package
         // every user will be able to see full post
         if (ConstsAndFuncs::IS_PAID == 0) {
             $DisplayedQuestions = -1;
         }
     }
     $photo = $post['Photo'];
     if ($DisplayedQuestions > 0) {
         $questions = Questions::where('PostID', '=', $postID)->take($DisplayedQuestions)->get()->toArray();
     } else {
         $questions = Questions::where('PostID', '=', $postID)->get()->toArray();
     }
     $AnswersFor1 = array();
     $TrueAnswersFor1 = array();
     $AnswersFor2 = array();
     $Spaces = array();
     $SetOfSpaceIDs = array();
     $Subquestions = array();
     $AnswersFor5 = array();
     $QuestionFor5IDs = array();
     $AnswersFor6 = array();
     $DragDropIDs = array();
     $CompleteAnswersFor6 = array();
     $AnswersFor3 = array();
     $AnswersFor4 = array();
     $FillCharacterIDs = array();
     $ArrangedIDs = array();
     $maxscore = 0;
     foreach ($questions as $q) {
         switch ($q['FormatID']) {
             case 1:
                 // Trắc nghiệm
                 $answers = Answers::where('QuestionID', '=', $q['id'])->get()->toArray();
                 foreach ($answers as $a) {
                     if ($a['Logical'] == 1) {
                         $TrueAnswersFor1 += [$q['id'] => $a['id']];
                         break;
                     }
                 }
                 $info = [$q['id'] => $answers];
                 if (count($answers) > 0) {
                     $maxscore++;
                 }
                 $AnswersFor1 += $info;
                 continue;
             case 2:
//.........这里部分代码省略.........
开发者ID:ngocdon0127,项目名称:kids,代码行数:101,代码来源:PostsController.php

示例15: show

 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);
 }
开发者ID:austin43,项目名称:personal-site,代码行数:6,代码来源:ViewPost.php


注:本文中的app\Posts::where方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。