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


PHP Category::orderBy方法代码示例

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


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

示例1: paginate

 /**
  * @param int $page
  * @param int $limit
  * @param bool $all
  * @return mixed|\StdClass
  */
 public function paginate($page = 1, $limit = 10, $all = false)
 {
     $result = new \StdClass();
     $result->page = $page;
     $result->limit = $limit;
     $result->totalItems = 0;
     $result->items = array();
     $query = $this->category->orderBy('title');
     $categories = $query->skip($limit * ($page - 1))->take($limit)->where('lang', $this->getLang())->get();
     $result->totalItems = $this->totalCategories();
     $result->items = $categories->all();
     return $result;
 }
开发者ID:phillipmadsen,项目名称:deved,代码行数:19,代码来源:CategoryRepository.php

示例2: getMasterDatas

 private function getMasterDatas()
 {
     $data['categories'] = Category::orderBy('title')->get();
     View::share('categories', $data['categories']);
     $data['locations'] = Location::all();
     View::share('locations', $data['locations']);
 }
开发者ID:huuson94,项目名称:btlltct,代码行数:7,代码来源:FEBaseController.php

示例3: getBlogShow

 /**
  * 博客文章展示页面
  * @param  string $slug 文章缩略名
  * @return response
  */
 public function getBlogShow($slug)
 {
     $article = Article::where('slug', $slug)->first();
     is_null($article) and App::abort(404);
     $categories = Category::orderBy('sort_order')->get();
     return View::make('blog.show')->with(compact('article', 'categories'));
 }
开发者ID:ningcaichen,项目名称:laravel-4.1-simple-blog,代码行数:12,代码来源:BlogController.php

示例4: getViewAllCategory

 /**
  *  This function responses to
  *  the get request of /admin/category
  *  and shows all category as list
  */
 public function getViewAllCategory($msg = null)
 {
     if (!empty($msg) && $msg == 1) {
         return View::make('adminArea.category.view')->with('categories', Category::orderBy('id', 'desc')->get())->with('success', 'Category has been deleted successfully');
     }
     return View::make('adminArea.category.view')->with('categories', Category::orderBy('id', 'desc')->get());
 }
开发者ID:madiarsa,项目名称:DVD-Rental,代码行数:12,代码来源:CategoryController.php

示例5: add

 public function add()
 {
     if (Request::isMethod('post')) {
         $rules = array('title' => 'required|min:4', 'link' => "required|unique:categories", 'meta_keywords' => 'required');
         $validator = Validator::make(Input::all(), $rules);
         if ($validator->fails()) {
             return Redirect::to("admin/category/add")->withErrors($validator)->withInput(Input::except(''));
         } else {
             $table = new Category();
             $table->title = Input::get('title');
             $table->link = Input::get('link');
             $table->content = Input::get('content');
             $table->parent_id = Input::get('parent_id') ? Input::get('parent_id') : null;
             $table->meta_title = Input::get('meta_title') ? Input::get('meta_title') : $table->title;
             $table->meta_description = Input::get('meta_description') ? Input::get('meta_description') : $table->title;
             $table->meta_keywords = Input::get('meta_keywords');
             $table->active = Input::get('active', 0);
             if ($table->save()) {
                 $name = trans("name.category");
                 return Redirect::to("admin/category")->with('success', trans("message.add", ['name' => $name]));
             }
             return Redirect::to("admin/category")->with('error', trans('message.error'));
         }
     }
     $categories = array(0 => 'Нет родительской категории') + Category::orderBy('title')->lists('title', 'id');
     return View::make("admin.shop.category.add", ['categories' => $categories, 'action' => $this->action]);
 }
开发者ID:Rotron,项目名称:shop,代码行数:27,代码来源:AdminCategoryController.php

示例6: getAll

 /**
  * 获取分类列表
  *
  * @param string  $taxonomy 
  * @param array   $credential 
  * @param boolean $tree
  *
  * @return object
  */
 public static function getAll(Closure $callback = null)
 {
     $terms = Category::orderBy('id', 'desc');
     if ($callback) {
         $callback($terms);
     }
     return $terms->get();
 }
开发者ID:ruanwenwu,项目名称:writor,代码行数:17,代码来源:Category.php

示例7: getCategory

 public function getCategory()
 {
     $category = Category::orderBy('order_type')->get();
     if ($category) {
         $response_array = array('success' => true, 'category' => $category);
     } else {
         $response_array = array('success' => false, 'error_msg' => "no data");
     }
     return Response::json($response_array);
 }
开发者ID:amrutjadhav,项目名称:Laravel_application,代码行数:10,代码来源:ApiController.php

示例8: run

 public function run()
 {
     DB::table('packages')->truncate();
     $faker = Faker\Factory::create();
     for ($i = 0; $i < 1; $i++) {
         $sentence = $faker->sentence(5);
         $slug = Str::slug($sentence);
         $user = User::orderBy(DB::raw('RAND()'))->first()->id;
         $category = Category::orderBy(DB::raw('RAND()'))->first()->id;
         $posts = array(['title_en' => $sentence, 'title_ar' => $sentence, 'description_en' => $sentence, 'description_ar' => $sentence, 'price' => '30', 'free' => 0, 'created_at' => $faker->DateTime(), 'updated_at' => $faker->DateTime()]);
         DB::table('packages')->insert($posts);
     }
 }
开发者ID:christiannwamba,项目名称:laravel-site,代码行数:13,代码来源:PackagesTableSeeder.php

示例9: run

 public function run()
 {
     DB::table('posts')->truncate();
     $dt = Carbon::now();
     $faker = Faker\Factory::create();
     for ($i = 0; $i < 1; $i++) {
         $sentence = $faker->sentence(5);
         $slug = Str::slug($sentence);
         $user = User::orderBy(DB::raw('RAND()'))->first()->id;
         $category = Category::orderBy(DB::raw('RAND()'))->first()->id;
         $posts = array(['user_id' => $user, 'category_id' => $category, 'title_ar' => $sentence, 'title_en' => $sentence, 'description_ar' => $faker->sentence(200), 'description_en' => $faker->sentence(200), 'created_at' => $dt, 'updated_at' => $dt]);
         DB::table('posts')->insert($posts);
     }
 }
开发者ID:christiannwamba,项目名称:laravel-site,代码行数:14,代码来源:PostsTableSeeder.php

示例10: modifView

 public function modifView($post_id)
 {
     $post_id = strip_tags($post_id);
     $post_id = intval($post_id);
     $post_id = filter_var($post_id, FILTER_VALIDATE_INT);
     $post = Post::with('category', 'user')->where('post_id', '=', $post_id)->get();
     $action = str_replace(':post_id', $post_id, $this->app->urlFor('post_modif'));
     $cancel = $this->app->urlFor('posts');
     $categories = Category::orderBy('category')->get();
     if (isset($_SESSION['vars'])) {
         unset($_SESSION['vars']);
     }
     $this->view = new PostModif($post, $action, $cancel, $categories);
     $this->view->display();
 }
开发者ID:alsvader,项目名称:percasBlog,代码行数:15,代码来源:PostController.class.php

示例11: getTags

 public function getTags()
 {
     if (Session::get('user_level') < Config::get('cms.viewComments')) {
         return Redirect::to(_l(URL::action('AdminHomeController@getIndex')))->with('message', Lang::get('admin.notPermitted'))->with('notif', 'warning');
     }
     $this->setLayout();
     if (Input::get('q')) {
         $categories = Category::where('title', 'LIKE', '%' . Input::get('q') . '%')->where('tag', '=', 1)->orderBy('title')->paginate(20);
     } else {
         $categories = Category::orderBy('title')->where('tag', '=', 1)->paginate(20);
     }
     View::share('title', __(Lang::get('admin.tags')));
     View::share('categories', $categories);
     $this->layout->content = View::make('backend.categories.index');
 }
开发者ID:Puskice,项目名称:PuskiceCMS,代码行数:15,代码来源:CategoryController.php

示例12: search

 /**
  * Show search result
  * @return response
  */
 public function search()
 {
     $query = Article::orderBy('created_at', 'desc')->where('post_status', 'open');
     $categories = Category::orderBy('sort_order')->get();
     // Get search conditions
     switch (Input::get('target')) {
         case 'title':
             $title = Input::get('like');
             break;
     }
     // Construct query statement
     isset($title) and $query->where('title', 'like', "%{$title}%")->orWhere('content', 'like', "%{$title}%");
     $articles = $query->paginate(6);
     return View::make('article.search')->with(compact('articles', 'categories'));
 }
开发者ID:rimshavbase,项目名称:timefragment,代码行数:19,代码来源:ArticleController.php

示例13: getCategories

 public static function getCategories()
 {
     $arrData = '';
     if (Cache::has('categories')) {
         $arrData = Cache::get('categories');
     } else {
         $categories = Category::orderBy('order_no')->get();
         $arrData = [];
         if (!$categories->isEmpty()) {
             $arrData = $categories->toArray();
         }
         Cache::forever('categories', $arrData);
     }
     return $arrData;
 }
开发者ID:nguyendaivu,项目名称:imagestock,代码行数:15,代码来源:Home.php

示例14: get_index

 public function get_index()
 {
     $admin = Auth::user();
     $mp3s = MP3::orderBy('created_at', 'desc')->take(10)->get();
     $mp3scount = MP3::count();
     $mp4s = MP4::orderBy('created_at', 'desc')->take(10)->get();
     $mp4scount = MP4::count();
     $users = User::orderBy('created_at', 'desc')->take(10)->get();
     $userscount = User::count();
     $categories = Category::orderBy('name')->take(10)->get();
     $catscount = Category::count();
     $pages = Page::orderBy('created_at', 'desc')->paginate(10);
     $pages_count = Page::count();
     $title = 'Administrasyon';
     return View::make('admin.index')->withAdmin($admin)->withMp3s($mp3s)->withMp4s($mp4s)->withUsers($users)->withCategories($categories)->withPages($pages)->withTitle($title)->withMp3sCount($mp3scount)->withMp4sCount($mp4scount)->withUsersCount($userscount)->withCatsCount($catscount)->withPagesCount($pages_count);
 }
开发者ID:jgbneatdesign,项目名称:tikwenpam,代码行数:16,代码来源:AdminController.php

示例15: getIndex

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function getIndex()
 {
     View::share('title', __(Lang::get('admin.dashboard')));
     $news = News::where('post_type', '=', 1)->orderBy('created_at', 'desc')->take(5)->get();
     $comments = Comment::orderBy('created_at', 'desc')->take(5)->get();
     $users = User::orderBy('created_at', 'desc')->take(5)->get();
     $files = Files::orderBy('created_at', 'desc')->take(5)->get();
     $categories = Category::orderBy('created_at', 'desc')->take(5)->get();
     $pages = News::where('post_type', '=', 2)->orderBy('created_at', 'desc')->take(5)->get();
     View::share('news', $news);
     View::share('comments', $comments);
     View::share('users', $users);
     View::share('files', $files);
     View::share('pages', $pages);
     View::share('categories', $categories);
     $this->setLayout();
     $this->layout->content = View::make('backend.content.dashboard');
 }
开发者ID:Puskice,项目名称:PuskiceCMS,代码行数:23,代码来源:AdminHomeController.php


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