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


PHP Post::whereRaw方法代码示例

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


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

示例1: getMore

 public function getMore($excludes)
 {
     $excludes = explode("SEPARATOR", $excludes);
     $whereString = "";
     foreach ($excludes as $exclude) {
         $whereString = $whereString . "slug != ? AND ";
     }
     $whereString = substr($whereString, 0, -5);
     $posts = Post::whereRaw($whereString, $excludes)->take(3)->orderBy("created_at", "desc")->get();
     return view("posts.ajax")->with("posts", $posts);
 }
开发者ID:voidgraphics,项目名称:Void-Portfolio,代码行数:11,代码来源:PostsController.php

示例2: postsList

 public function postsList($nodeId = '')
 {
     $nodeIds = DB::table('node_hierarchy')->where('node_parent_id', '=', $nodeId)->lists('node_id');
     $nodeIds = array_merge($nodeIds, [$nodeId]);
     $nodeIds = implode(',', $nodeIds);
     //        if($nodeId==''){
     //            $posts = Post::paginate(10);
     //            $node = '';
     //        }else{
     $posts = Post::whereRaw("node_id in ({$nodeIds})")->orderBy('created_at', 'DESC')->paginate(6);
     $node = Node::find($nodeId);
     //        }
     //dd(response()->json(view('home.post.posts',compact('posts'))->render()));
     if (Request::ajax()) {
         return response()->json(view('home.post.posts', compact('posts'))->render());
     }
     return view('home.post.index', compact('posts', 'node'));
 }
开发者ID:nutsdo,项目名称:rp-wechat,代码行数:18,代码来源:PostController.php

示例3: boot

 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     # Share variable cross views
     if (Schema::hasTable('posts')) {
         $totalnewposts = Post::whereRaw('DATE(created_at) >= DATE_SUB(NOW(),INTERVAL 30 DAY)')->count();
     } else {
         $totalnewposts = 0;
     }
     # Get all backgrounds filenames in an array
     # For random Background $backgrounds->random()
     $backgrounds = collect(Storage::disk('backgrounds')->allFiles());
     view()->share(['totalnewposts' => $totalnewposts, 'backgrounds' => $backgrounds]);
     Validator::extend('farsi', function ($attribute, $value, $parameters) {
         return preg_match('/^[اآإأبپتثجچحخدذرزژسشصضظطعغفقکگلمنوؤهةۀیئيءـًٌٍَُِِّ\\s]+$/', $value);
     });
     Blade::extend(function ($value) {
         return preg_replace('/\\@define(.+)/', '<?php ${1}; ?>', $value);
     });
 }
开发者ID:majid-n,项目名称:cometdev,代码行数:24,代码来源:AppServiceProvider.php

示例4: show

 /**
  * @param $pid
  * @return \Response
  */
 public function show($pid)
 {
     if (empty($pid) || is_null($pid)) {
         abort(404);
     }
     $post = Post::findOrFail($pid);
     $prevPost = Post::whereRaw('id = (select max(id) from posts where id < ' . $pid . ')')->limit(1)->orderBy('id', 'asc')->first();
     $nextPost = Post::whereRaw('id = (select min(id) from posts where id > ' . $pid . ')')->limit(1)->orderBy('id', 'asc')->first();
     $data = ['post' => $post, 'photos' => [], 'videos' => [], 'links' => [], 'audios' => [], 'polls' => [], 'prevPostUrl' => is_null($prevPost) ? null : route('post_show', ['pid' => $prevPost->id]), 'nextPostUrl' => is_null($nextPost) ? null : route('post_show', ['pid' => $nextPost->id])];
     if (!is_null($post->attachments)) {
         foreach ($post->attachments as $attachment) {
             if ($attachment->type === 'album') {
                 $photos = $attachment->childs;
                 foreach ($photos as $photo) {
                     array_push($data['photos'], $photo);
                 }
                 continue;
             }
             array_push($data[$attachment->type . 's'], $attachment);
         }
     }
     return view('post.post', $data);
 }
开发者ID:stcoder,项目名称:uf-vova,代码行数:27,代码来源:PostController.php

示例5: slug

 /**
  * just a small API request to find the next slug
  * @param  Request $request [description]
  * @return [type]           [description]
  */
 public function slug(Request $request)
 {
     if (!$request->has('slug')) {
         return response()->json(['valid' => false, 'slug' => '']);
     }
     // generate the default slug
     $slug = str_slug($request->input('slug'));
     // check to see if one already exists
     $lastSlug = Post::whereRaw("slug RLIKE '^" . $slug . "(-[0-9]*)?\$'")->latest('created_at')->value('slug');
     if ($lastSlug) {
         // explode the parts
         $parts = explode('-', $lastSlug);
         $number = end($parts);
         $slug .= '-' . ($number + 1);
     }
     return response()->json(['valid' => true, 'slug' => $slug]);
 }
开发者ID:xchub,项目名称:laravel-blog,代码行数:22,代码来源:BlogController.php

示例6: filterCategory

 public function filterCategory(Request $request)
 {
     $posts = \App\Post::whereRaw('published_at <= ? and category_id = ?', array(Carbon::now(), $request->input("category")->value))->paginate(config('blog.posts_per_page'));
     return view('blog.index', compact('posts'));
 }
开发者ID:Alter93,项目名称:SimpleBlog,代码行数:5,代码来源:BlogController.php


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