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


PHP Director::where方法代码示例

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


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

示例1: getSearch

 public function getSearch($term = "")
 {
     if (Auth::user()->allow_search == 0) {
         App::abort(403, 'Insufficient permissions.');
     }
     $page_size = 24;
     $start = 0;
     if (Request::ajax()) {
         $search_term = Input::get('search_term');
     } else {
         $search_term = $term;
     }
     $actor_ids = Actor::where("name", "LIKE", "%" . $search_term . "%")->join('titles_actors', 'titles_actors.actor_id', '=', 'actors.id')->lists('title_id');
     $director_ids = Director::where("name", "like", "%" . $search_term . "%")->join('titles_directors', 'titles_directors.director_id', '=', 'directors.id')->lists('title_id');
     $producer_ids = Producer::where("name", "LIKE", "%" . $search_term . "%")->join('titles_producers', 'titles_producers.producer_id', '=', 'producers.id')->lists('title_id');
     $writer_ids = Writer::where("name", "LIKE", "%" . $search_term . "%")->join('titles_writers', 'titles_writers.writer_id', '=', 'writers.id')->lists('title_id');
     $ids = array_merge($actor_ids, $director_ids, $producer_ids, $writer_ids);
     if (empty($ids)) {
         $ids = array(0);
     }
     $myFaves = Favorite::where("user_id", "=", Auth::user()->id)->get();
     $fave_array = array();
     foreach ($myFaves as $fave_rec) {
         $fave_array[] = $fave_rec->title_id;
     }
     if (Request::ajax()) {
         if (Input::has('page')) {
             $start = (intval(Input::get('page')) - 1) * $page_size;
         }
         $return_more = Input::get('fetch') == "more";
         $columns = $return_more ? array("*") : array("id", "name");
         $tmptitles = Title::select($columns)->where('status_id', '=', '3')->where(function ($query) use($search_term, $ids) {
             $query->whereIn("id", $ids)->orWhere("name", "like", "%" . $search_term . "%")->orWhere("actors", "like", "%" . $search_term . "%")->orWhere("directors", "like", "%" . $search_term . "%")->orWhere("producers", "like", "%" . $search_term . "%")->orWhere("writers", "like", "%" . $search_term . "%");
         });
         if ($return_more) {
             $tmptitles = $tmptitles->with(array("genre", "thumbnail"));
             $titles = array_slice($tmptitles->get()->toArray(), $start, $page_size);
             foreach ($titles as $key => $title) {
                 // error_log($title);
                 if (in_array($title['id'], $fave_array)) {
                     $titles[$key]['faved'] = 1;
                 } else {
                     $titles[$key]['faved'] = 0;
                 }
                 if (count($title['thumbnail']) > 0) {
                     $titles[$key]['thumbpath'] = asset(Config::get('nbc.imageRootImagePath') . '/' . $title['thumbnail'][0]['file']);
                 } else {
                     $titles[$key]['thumbpath'] = asset('images/publicThumb.jpg');
                     //unset($titles[$key])
                 }
             }
             return json_encode(array('titles' => View::make('titles.title_grid_template', array('titles' => $titles, 'mode' => "normal"))->render(), 'totalCount' => $tmptitles->count(), 'mode' => 'search_mode', 'currentPageCount' => count($titles)));
         } else {
             $titles = $tmptitles->get()->toArray();
             foreach ($titles as $key => $title) {
                 $titles[$key]['name'] = repair_a_the($title['name']);
             }
             return $this->makeSuccessArray(true, array("title_results" => $titles, "found" => count($titles) ? "1" : "0"));
         }
     } else {
         $search_term = $term;
         $genre_param = "";
         // placeholder stuff
         $genre_label = "Results for: ";
         $genre_label .= "<span style='font-size:35px'>&ldquo;</span>";
         $genre_label .= $search_term;
         $genre_label .= "<span style='font-size:35px'>&rdquo;</span>";
         // Prep the left sidebar filtering widget data
         $genres = Genre::orderBy("name", "asc")->get()->toArray();
         $sidebar_categories = $this->getCategoriesForSidebar();
         // If this input exists, it means User clicked "Add More Titles" button
         // From the "View Collections" page
         if (Input::has('default_collection_id')) {
             $default_collection_id = Input::get('default_collection_id');
         } else {
             $default_collection_id = $this->getUserLastCollectionUsed();
         }
         $user_id = Auth::user()->id;
         //$collections = Collection::where("user_id","=",$user_id)->get(array('id', 'name'))->toArray();
         $collections = Collection::select('id', 'name')->where("user_id", "=", $user_id)->where("status_id", "<>", 6)->orderBy('name')->get()->toArray();
         $collection_dropdown = array();
         foreach ($collections as $collection) {
             $shortened_coll_name = str_limit($collection['name'], 25);
             $collection_dropdown[$collection['id']] = $shortened_coll_name;
         }
         if (isset($default_collection_id) && $default_collection_id) {
             $first_collection_id = $default_collection_id;
         } else {
             reset($collection_dropdown);
             $first_collection_id = key($collection_dropdown);
         }
         // ------------------  Finally, the actual query to get matching titles ------------------
         $tempresults = Title::with(array("genre", "thumbnail", "producttype"))->where('status_id', '=', '3')->where(function ($query) use($search_term, $ids) {
             $query->whereIn("id", $ids)->orWhere("name", "like", "%" . $search_term . "%")->orWhere("actors", "like", "%" . $search_term . "%")->orWhere("directors", "like", "%" . $search_term . "%")->orWhere("producers", "like", "%" . $search_term . "%")->orWhere("writers", "like", "%" . $search_term . "%");
         });
         $results = array_slice($tempresults->get()->toArray(), $start, $page_size);
         foreach ($results as $key => $title) {
             if (in_array($title['id'], $fave_array)) {
                 $results[$key]['faved'] = 1;
             } else {
//.........这里部分代码省略.........
开发者ID:ke6scs,项目名称:samples,代码行数:101,代码来源:TitleController.php


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