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


PHP Post::where方法代码示例

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


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

示例1: postView

 /**
  * View a blog post.
  *
  * @param  string  $slug
  * @return Redirect
  */
 public function postView($slug)
 {
     $user = $this->user->currentUser();
     $canComment = $user->can('post_comment');
     if (!$canComment) {
         return Redirect::to($slug . '#comments')->with('error', 'You need to be logged in to post comments!');
     }
     // Get this blog post data
     $post = $this->post->where('slug', '=', $slug)->first();
     // Declare the rules for the form validation
     $rules = array('comment' => 'required|min:3');
     // Validate the inputs
     $validator = Validator::make(Input::all(), $rules);
     // Check if the form validates with success
     if ($validator->passes()) {
         // Save the comment
         $comment = new Comment();
         $comment->user_id = Auth::user()->id;
         $comment->content = Input::get('comment');
         // Was the comment saved with success?
         if ($post->comments()->save($comment)) {
             // Redirect to this blog post page
             return Redirect::to($slug . '#comments')->with('success', 'Your comment was added with success.');
         }
         // Redirect to this blog post page
         return Redirect::to($slug . '#comments')->with('error', 'There was a problem adding your comment, please try again.');
     }
     // Redirect to this blog post page
     return Redirect::to($slug)->withInput()->withErrors($validator);
 }
开发者ID:hilmysyarif,项目名称:l4-bootstrap-admin,代码行数:36,代码来源:BlogController.php

示例2: post

 public function post($link)
 {
     $table = Post::where('link', '=', $link)->firstOrFail();
     $table->content = e($table->content);
     $table->save();
     return View::make('blog.post', ['post' => Post::where('link', '=', $link)->firstOrFail()]);
 }
开发者ID:Rotron,项目名称:shop,代码行数:7,代码来源:BlogController.php

示例3: getComment

 public function getComment()
 {
     $id = Auth::id();
     $postList = Post::where("author_id", $id)->get(array('_id'));
     $postIdList = array();
     foreach ($postList as $post) {
         //                echo $post->_id;
         //              echo "<br>";
         array_push($postIdList, $post->_id);
     }
     $comment_data = Comment::whereIn('post_id', $postIdList)->get();
     //echo count($comment_data);
     foreach ($comment_data as $comment) {
         $user_id = $comment['user_id'];
         $user = User::getUserById($user_id);
         $post = Post::where('_id', $comment->post_id)->first();
         $comment['title'] = $post['title'];
         $comment['username'] = $user['username'];
         $comment['email'] = $user['email'];
         $format = "F j, Y, g:i a";
         $date = new DateTime($comment['updated_at']);
         $formatDate = $date->format($format);
         $comment['update_time'] = $formatDate;
         if (isset($user['fb_img'])) {
             $comment['fb_img'] = $user['fb_img'];
         }
     }
     return View::make('backend.comment', array('comment_data' => $comment_data));
 }
开发者ID:Hungmaix94,项目名称:Medusa,代码行数:29,代码来源:AdminController.php

示例4: testLists

 public function testLists()
 {
     $lists = Post::where('views', '>=', 10)->lists('id', 'title');
     $debug = last(DB::getQueryLog());
     $this->assertEquals(['Bar' => 2, 'FooBar' => 3], $lists);
     $this->assertEquals('select "id", "title" from "posts" where "published" = ? and "views" >= ? and "status" = ?', $debug['query']);
 }
开发者ID:pixelpeter,项目名称:eloquent-filterable,代码行数:7,代码来源:EloquentFilterTest.php

示例5: postView

 /**
  * View a blog post.
  *
  * @param  string  $slug
  * @return Redirect
  */
 public function postView($slug)
 {
     // The user needs to be logged in, make that check please
     if (!Sentry::check()) {
         return Redirect::to("blog/{$slug}#comments")->with('error', 'You need to be logged in to post comments!');
     }
     // Get this blog post data
     $post = Post::where('slug', $slug)->first();
     // Declare the rules for the form validation
     $rules = array('comment' => 'required|min:3');
     // Create a new validator instance from our dynamic rules
     $validator = Validator::make(Input::all(), $rules);
     // If validation fails, we'll exit the operation now
     if ($validator->fails()) {
         // Redirect to this blog post page
         return Redirect::to("blog/{$slug}#comments")->withInput()->withErrors($validator);
     }
     // Save the comment
     $comment = new Comment();
     $comment->user_id = Sentry::getUser()->id;
     $comment->content = e(Input::get('comment'));
     // Was the comment saved with success?
     if ($post->comments()->save($comment)) {
         // Redirect to this blog post page
         return Redirect::to("blog/{$slug}#comments")->with('success', 'Your comment was successfully added.');
     }
     // Redirect to this blog post page
     return Redirect::to("blog/{$slug}#comments")->with('error', 'There was a problem adding your comment, please try again.');
 }
开发者ID:forestallers,项目名称:laravel-starter-kit,代码行数:35,代码来源:BlogController.php

示例6: postView

 /**
  * View a blog post.
  *
  * @param  string  $slug
  * @return Redirect
  */
 public function postView($slug)
 {
     $user = $this->user->currentUser();
     $canComment = $user->can('post_comment');
     if (!$canComment) {
         return Redirect::to($slug . '#comments')->with('error', Lang::get('site.login_to_post'));
     }
     // Get this blog post data
     $post = $this->post->where('slug', '=', $slug)->first();
     // Declare the rules for the form validation
     $rules = array('comment' => 'required|min:3', 'comment_hp' => 'honeypot', 'comment_time' => 'required|honeytime:5');
     // Validate the inputs
     $validator = Validator::make(Input::all(), $rules);
     // Check if the form validates with success
     if ($validator->passes()) {
         // Save the comment
         $comment = new Comment();
         $comment->user_id = Auth::user()->id;
         $comment->content = Input::get('comment');
         // Was the comment saved with success?
         if ($post->comments()->save($comment)) {
             // Redirect to this blog post page
             return Redirect::to($slug . '#comments')->with('success', Lang::get('site.comment_added'));
         }
         // Redirect to this blog post page
         return Redirect::to($slug . '#comments')->with('error', Lang::get('site.comment_not_Added'));
     }
     // Redirect to this blog post page
     return Redirect::to($slug)->withInput()->withErrors($validator);
 }
开发者ID:Aranjedeath,项目名称:l4-starter,代码行数:36,代码来源:BlogController.php

示例7: __construct

 public function __construct(Reservation $reservation)
 {
     $this->reservation = $reservation;
     View::share('locations', Location::orderBy('name', 'asc')->get());
     View::share('types', Type::orderBy('name', 'asc')->get());
     View::share('news', Post::where('post_type', 'news')->orderBy('created_at', 'desc')->limit(4)->get());
 }
开发者ID:jacobDaeHyung,项目名称:Laravel-Real-Estate-Manager,代码行数:7,代码来源:PropertyController.php

示例8: getAccount

 public function getAccount()
 {
     $news = Post::where('parent', '=', '7')->get();
     $projects = Project::limit(10)->get();
     $view = array('news' => $news, 'projects' => $projects);
     return View::make('user.account', $view);
 }
开发者ID:ldin,项目名称:project_media,代码行数:7,代码来源:UsersController.php

示例9: post_list

function post_list()
{
    // only run on the first call
    if (!Registry::has('rwar_post_archive')) {
        // capture original article if one is set
        if ($article = Registry::get('article')) {
            Registry::set('original_article', $article);
        }
    }
    if (!($posts = Registry::get('rwar_post_archive'))) {
        $posts = Post::where('status', '=', 'published')->sort('created', 'desc')->get();
        Registry::set('rwar_post_archive', $posts = new Items($posts));
    }
    if ($result = $posts->valid()) {
        // register single post
        Registry::set('article', $posts->current());
        // move to next
        $posts->next();
    } else {
        // back to the start
        $posts->rewind();
        // reset original article
        Registry::set('article', Registry::get('original_article'));
        // remove items
        Registry::set('rwar_post_archive', false);
    }
    return $result;
}
开发者ID:boryszielonka,项目名称:anchor-post-loop,代码行数:28,代码来源:post-loop.php

示例10: showStatusPage

 /**
  * TODO: Documentation
  * @param type $groupid
  * @return type
  */
 public function showStatusPage($groupid)
 {
     if (empty($groupid)) {
         App::abort(404);
     }
     $user = Auth::user();
     $group = Group::find($groupid);
     // I will have to fetch the user's current group
     $userCurrentTask = $user->getPendingTask($group->id, $group->outcome);
     if ($userCurrentTask) {
         $task = Task::find($userCurrentTask[0]->task_id);
         // I will have to fetch the user's curent task
     } else {
         $task = Task::find(5);
     }
     // TODO: fetch the posts for this group
     $posts = Post::orderBy('id', 'DESC')->where('group_id', $group->id)->take(5)->get();
     $postCount = Post::where('group_id', $group->id)->count();
     $current = new stdClass();
     $current->user = $user->id;
     $current->group = $group->id;
     $current->task = $task->id;
     $this->layout->bodyclasses = 'status-page';
     $this->layout->content = View::make('play.status')->with('user', $user)->with('group', $group)->with('task', $task)->with('current', $current)->with('posts', $posts)->with('postcount', $postCount);
 }
开发者ID:RHoKAustralia,项目名称:onaroll21_backend,代码行数:30,代码来源:PlayController.php

示例11: getPagesDatatables

 /**
  * @name getPagesDatatables
  *
  * Gets data for pages datatables
  * 
  * @return Response - returns Respons in json format including data for datatables or error
  */
 public function getPagesDatatables()
 {
     $pages = Post::where('type', 'page')->whereNotIn('status', array('trash', 'auto-draft'));
     $total = $pages->count();
     $result = $pages->with("post_contents")->get()->toArray();
     return Response::json(array("sEcho" => 1, "iTotalRecords" => $total, "iTotalDisplayRecords" => $total, "aaData" => $result));
 }
开发者ID:ayurved,项目名称:Ayurveda,代码行数:14,代码来源:PageApiController.php

示例12: show

 /**
  * Display the specified category.
  *
  * @param  string $slug
  * @return Response
  */
 public function show($slug)
 {
     //return le slug de la categorie
     $categories = Category::where('slug', $slug)->firstOrFail();
     $posts = Post::where('category_id', '=', $categories->id)->orderBy('published_at', 'desc')->paginate(5);
     return View::make('categories.show', compact('categories', 'posts', 'author'));
 }
开发者ID:uknowcreation,项目名称:laravelblog,代码行数:13,代码来源:CategoriesController.php

示例13: index

 public function index()
 {
     $page = Post::where('permalink', '=', 'welcome')->first();
     $slides = Slideshow::latest()->get();
     $this->layout->title = 'Home';
     $this->layout->content = View::make('public.' . $this->current_theme . '.index')->with('page', $page)->with('slides', $slides);
 }
开发者ID:doptor,项目名称:doptor,代码行数:7,代码来源:HomeController.php

示例14: get_parent

 public function get_parent()
 {
     if (isset($this->parent)) {
         return $this->parent;
     }
     $this->parent = Post::where(['id' => $this->parent_id])->first();
     return $this->parent;
 }
开发者ID:JCQS04,项目名称:myimouto,代码行数:8,代码来源:ParentMethods.php

示例15: index

 public function index()
 {
     $victories = Victory::orderBy('created_at', 'DESC')->limit(4)->get();
     $blogs = Blog::orderBy('created_at', 'DESC')->limit(4)->get();
     $images = Post::where('is_carasaul', '=', 1)->get();
     $testimonials = Testimonial::orderBy('created_at', 'DESC')->limit(1)->get();
     return View::make('pages.index', compact('images', 'testimonials', 'victories', 'blogs'));
 }
开发者ID:shankargiri,项目名称:taylor_latest,代码行数:8,代码来源:PagesController.php


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