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


PHP News::where方法代码示例

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


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

示例1: autocomplete

 public function autocomplete()
 {
     $term = Request::input('term');
     $search = News::where('nTitle', 'LIKE', '%' . $term . '%')->get();
     foreach ($search as $item) {
         $result[] = array('value' => $item->nTitle);
     }
     return Response::json($result);
 }
开发者ID:haclongkim,项目名称:newsedu,代码行数:9,代码来源:HomeController.php

示例2: news

 /**
  * Get the news entries tagged to me
  * @param int $limit
  * @return \Eloquent
  */
 public function news($limit = 5)
 {
     if (count($this->newsLatest) >= 1) {
         return $this->newsLatest;
     }
     // get class name that include this file (model name)
     $parent = str_replace('AppModels', '', stripslashes(static::class));
     $rows = DB::select("SELECT news.* FROM {$this->table}\n            INNER JOIN news_tag ON news_tag.subject_id = {$this->table}.id\n            INNER JOIN news ON news.id = news_tag.news_id\n            WHERE {$this->table}.id = ? AND news_tag.subject_type LIKE ?\n            GROUP BY news.id\n            ORDER BY news.created_at DESC", [$this->id, '%' . $parent]);
     $news = collect();
     // filter active and get photos for entry
     foreach ($rows as $k => $row) {
         $item = News::where('id', $row->id)->active()->first();
         if ($item) {
             $item->images;
             // get the images
             $news->push($item);
         }
     }
     $this->newsLatest = $news->take($limit);
     return $this->newsLatest;
     // old / default way
     return $this->hasMany(NewsTag::class, 'subject_id', 'id')->where('subject_type', get_class($this))->with('news')->orderBy('created_at', 'DESC');
 }
开发者ID:bpocallaghan,项目名称:titan,代码行数:28,代码来源:TaggedNews.php

示例3: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $news = News::where('published_at', '<=', Carbon::now())->where('enabled', '=', '1')->orderBy('published_at', 'desc')->paginate(config('news.posts_per_page'));
     return view('news.index', compact('news'));
 }
开发者ID:eok8177,项目名称:laravel,代码行数:10,代码来源:NewsController.php

示例4: frontendShow

 public function frontendShow($id)
 {
     $result = News::find($id);
     if (is_null($result)) {
         $result = News::where('slug', $id)->get()->first();
     }
     $title = $result->title;
     $result1 = DB::table('parent_menu')->get();
     $siteTitle = Setting::where('name', 'title')->get();
     if (count($siteTitle) > 0) {
         $bah = $siteTitle->first()->value;
     } else {
         $bah = 'Website';
     }
     $footer = Setting::where('name', 'footer')->get();
     if (count($footer) > 0) {
         $footer = $footer->first()->value;
     } else {
         $footer = '(c) 2015, Ordent, All Right Reserved.';
     }
     return view('frontend.news-show', compact('result', 'title', 'result1', 'footer'));
 }
开发者ID:k1m0ch1,项目名称:egor,代码行数:22,代码来源:NewsController.php

示例5: postDelete

 public function postDelete(Request $request)
 {
     $id = $request->input('id');
     $ReturnData = [];
     if (empty($id)) {
         $this->error = true;
         $this->error_message = "Dữ liệu không đúng, vui lòng thử lại";
         goto next;
     }
     $CheckHasPost = Models\News::where('group_news_id', $id)->count();
     if ($CheckHasPost == 0) {
         try {
             $rs = Models\Group_news::find($id)->delete();
         } catch (Exception $e) {
             $this->error = true;
             $this->error_message = "Truy vấn lỗi, vui lòng thử lại";
             goto next;
         }
     } else {
         $this->error = true;
         $this->error_message = "Vui lòng xóa hết bản tin trong chuyên mục này !";
         goto next;
     }
     $this->error_message = "Thành công";
     next:
     return $this->ResponseData($ReturnData);
 }
开发者ID:dao94,项目名称:game,代码行数:27,代码来源:GroupnewsController.php


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