本文整理汇总了PHP中app\models\Category::orderBy方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::orderBy方法的具体用法?PHP Category::orderBy怎么用?PHP Category::orderBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Category
的用法示例。
在下文中一共展示了Category::orderBy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$pro = new Product();
$adSlotObj = new Adslot();
$catObj = new Category();
$brandObj = new Brand();
/*getting all products for all slots(currently we have 7 slots)*/
$adSlot_data = $adSlotObj->with(['products'])->get();
/*t1-t7*/
// dd($adSlot_data[4]['products'][0]);
$category_temp_data = $catObj->orderBy('created_at')->take(10)->get();
/*f1-f10*/
$brand_data = $brandObj->with(['products'])->get();
$category_data = [];
foreach ($category_temp_data as $cat_id) {
$cat_latest_product = $pro->where('category_id', '=', $cat_id['id'])->orderBy('created_at')->take(1)->pluck('photo_1');
$cat_latest_product_id = $pro->where('category_id', '=', $cat_id['id'])->orderBy('created_at')->take(1)->pluck('id');
$cat_random_product = $pro->where('category_id', '=', $cat_id['id'])->orderBy(DB::raw('RAND()'))->take(6)->get();
$cat_brands = $pro->with(['brand'])->where('category_id', '=', $cat_id['id'])->take(5)->get();
$cat_products_random_photos = [];
foreach ($cat_random_product as $photo) {
$cat_products_random_photos[] = $photo;
}
$category_data[] = ['color' => $cat_id['color'], 'floor' => $cat_id['floor'], 'name' => $cat_id['name'], 'desc' => $cat_id['description'], 'logo' => $cat_id['logo'], 'latest_photo_id' => $cat_latest_product_id, 'latest_photo' => $cat_latest_product, 'random_photos' => $cat_products_random_photos, 'brands' => $cat_brands];
}
return view('landing_page', compact(['adSlot_data', 'category_data']));
}
示例2: getIndex
public function getIndex($status = 'Pending')
{
$status = ucfirst($status);
if ($status != 'Pending') {
$query = Confession::orderBy('created_at', 'desc');
} else {
$query = Confession::orderBy('created_at', 'asc');
}
if (\Input::get('category')) {
$query->whereHas('categories', function ($query) {
$query->where('confession_categories.confession_category_id', '=', intval(\Input::get('category')));
});
}
if (\Input::get('q')) {
$search = stripslashes(\Input::get('q'));
$query->where('content', 'LIKE', "%{$search}%");
}
if (\Input::get('start') && \Input::get('end')) {
$start = Carbon::createFromFormat('U', strtotime(\Input::get('start')))->startOfDay();
$end = Carbon::createFromFormat('U', strtotime(\Input::get('end')))->startOfDay();
if ($start > $end) {
return \Redirect::back()->withMessage('Start date cannot be later than end date.')->with('alert-class', 'alert-danger');
}
$query->where('created_at', '>=', $start->toDateTimeString());
$query->where('created_at', '<', $end->toDateTimeString());
}
if ($status != 'All') {
$query->where('status', '=', ucfirst($status));
}
$confessions = $query->with('moderatorComments')->paginate(10);
return view('admin.confessions.index', ['confessions' => $confessions, 'categoryOptions' => array_merge(array('All Categories' => 0), Category::orderBy('confession_category', 'asc')->lists('confession_category_id', 'confession_category')), 'hasPageToken' => (bool) $this->confessionsRepo->getPageToken()]);
}
示例3: index
public function index()
{
$categories = Category::orderBy('name')->paginate(30);
// if (Request::isMethod('get'))
// {
// $whereConditions = [];
// if(!empty(Input::all()))
// {
// foreach (Input::all() as $key => $input)
// {
// if(!empty($input) && $key!='page' && $key!='_token')
// $whereConditions[$key] = $input;
// }
// $fishs = Category::where($whereConditions)->paginate(30);
// }
// else
// {
// $fishs = Category::orderBy('name_ro')->paginate(30);
// }
// }
// else
// {
// $fishs = Category::orderBy('name')->paginate(30);
// }
Request::flash();
return view('Admin.category.index')->with(['categories' => $categories])->withInput(Input::all());
}
示例4: get_categories
private function get_categories()
{
$categories = Cache::rememberForever('wyshop_admin_category_categories', function () {
$categories = Category::orderBy('parent_id', 'asc')->orderBy('sort_order', 'asc')->orderBy('id', 'asc')->get();
return tree($categories);
});
return $categories;
}
示例5: getMenuCategory
public function getMenuCategory($active = "")
{
$Model = new Category();
$Data = $Model->orderBy('id', 'DESC');
if (!empty($active)) {
$Data = $Data->where('active', $active);
}
return $Data->get()->toArray();
}
示例6: categoryList
public static function categoryList($category_type = null)
{
$categories = Category::orderBy('name', 'asc')->whereNull('deleted_at')->orderBy('name', 'asc');
if (!empty($category_type)) {
$categories = $categories->where('category_type', '=', $category_type);
}
$category_list = array('' => trans('general.select_category')) + $categories->pluck('name', 'id')->toArray();
return $category_list;
}
示例7: run
public function run()
{
$faker = Faker\Factory::create();
DB::table('advertisement')->delete();
foreach (range(1, 30) as $index) {
$category_id = Category::orderBy(DB::raw('RAND()'))->first()->id;
$city_id = Cities::orderBy(DB::raw('RAND()'))->first()->id;
$type_id = AdType::orderBy(DB::raw('RAND()'))->first()->id;
// $a_hash = AdsAttachment::orderBy(DB::raw('RAND()'))->first()->hash;
Advertisement::create(['category_id' => $category_id, 'text' => $faker->paragraph(4), 'user_id' => 1, 'city_id' => $city_id, 'type_id' => $type_id, 'price' => 12345, 'approved' => rand(0, 1)]);
}
}
示例8: detail
public function detail($id)
{
$page = 'catalog';
$title = Menu::where('key', $page)->value('name');
$menuHtml = $this->menuHtml($page);
$menuItems = Menu::all();
$bottomMenuHtml = view('bottom', ['menuItems' => $menuItems])->render();
$pageInfo = Page::where('key', $page)->first();
$categories = Category::orderBy('sort', 'asc')->get();
$product = Product::with(['category', 'color'])->find($id);
$product->increment('views');
$recommended = Product::with('category')->take(4)->get();
$smallCart = $this->smallCart();
$cartItem = $this->cartItem($product->id);
$page = $product;
$page->title = $product->name;
return view('site.product', ['menuHtml' => $menuHtml, 'menuBottomHtml' => $bottomMenuHtml, 'title' => $title, 'page' => $page, 'product' => $product, 'categories' => $categories, 'recommended' => $recommended, 'count' => $smallCart['count'], 'sum' => $smallCart['sum'], 'currentItem' => $cartItem, 'currentProductCategory' => $product->category]);
}
示例9: index
public function index($page = '')
{
// $title = Menu::where('key', $page)->value('name');
$categories = Category::orderBy('sort', 'asc')->get();
$menuHtml = $this->menuHtml($page);
if (session()->has('cart')) {
$cartItems = session()->get('cart');
$sum = $cartItems->sum();
$count = count($cartItems->all());
} else {
$sum = 0;
$count = 0;
}
$menuItems = Menu::all();
$products = Product::with('category')->orderBy('views', 'desc')->take(8)->get();
$bottomMenuHtml = view('bottom', ['menuItems' => $menuItems])->render();
$page = Page::where('key', 'index')->first();
return view('index', ['menuHtml' => $menuHtml, 'menuBottomHtml' => $bottomMenuHtml, 'categories' => $categories, 'count' => $count, 'sum' => $sum, 'products' => $products, 'indexFlag' => true, 'page' => $page]);
}
示例10: boot
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
\View::composer('frontend.partials.sidebar', function ($view) {
/** @var \Illuminate\View\View $view */
Menu::make('sidebar', function ($menu) {
/** @var \Lavary\Menu\Builder $menu */
/** @var \Illuminate\Database\Eloquent\Collection $tree */
$tree = Category::orderBy('name', 'asc')->published()->get()->toHierarchy();
$tree->each(function (Category $category) use($menu) {
/** @var \Lavary\Menu\Item $item */
$item = $menu->add($category->name, ['route' => ['category.show', $category->slug]]);
if ($category->children->count() !== 0) {
$category->children->each(function (Category $category) use($item) {
$item->add($category->name, ['route' => ['category.show', $category->slug]]);
});
}
});
});
});
}
示例11: search
public function search(Request $request)
{
$page = new \stdClass();
$page->title = 'Поиск';
$page->keywords = 'Поиск';
$page->description = 'Поиск';
$page->key = 'search';
$menuHtml = $this->menuHtml('cart');
$menuItems = Menu::all();
$bottomMenuHtml = view('bottom', ['menuItems' => $menuItems])->render();
$categories = Category::orderBy('sort', 'asc')->get();
$smallCart = $this->smallCart();
if ($request->has('val')) {
$products = Product::where('name', 'like', "%{$request->val}%")->orWhere('text', 'like', "%{$request->val}%")->get();
$val = $request->get('val');
} else {
$val = '';
$products = [];
}
return view('site.search', ['menuHtml' => $menuHtml, 'menuBottomHtml' => $bottomMenuHtml, 'page' => $page, 'categories' => $categories, 'products' => $products, 'count' => $smallCart['count'], 'sum' => $smallCart['sum'], 'indexFlag' => true, 'search' => $val]);
}
示例12: index
public function index(Request $request)
{
$page = new \stdClass();
$page->title = 'Корзина';
$page->keywords = 'Корзина';
$page->description = 'Корзина';
$page->key = 'cart';
// $title = Menu::where('key', 'cart')->value('name');
$menuHtml = $this->menuHtml('cart');
$menuItems = Menu::all();
$bottomMenuHtml = view('bottom', ['menuItems' => $menuItems])->render();
// $page = Page::where('key', $page)->first();
$cart = $request->session()->get('cart');
if ($cart) {
$items = $cart->all();
} else {
$items = false;
}
$categories = Category::orderBy('sort', 'asc')->get();
$smallCart = $this->smallCart();
return view('site.cart', ['menuHtml' => $menuHtml, 'menuBottomHtml' => $bottomMenuHtml, 'page' => $page, 'items' => $items, 'categories' => $categories, 'count' => $smallCart['count'], 'sum' => $smallCart['sum'], 'deliverySum' => $smallCart['deliverySum'], 'totalSum' => $smallCart['deliverySum'] + $smallCart['sum']]);
}
示例13: foreach
function list_search_condition()
{
$user_searches = User_search::where('user_id', $this->user->id)->get();
foreach ($user_searches as &$user_search) {
if ($user_search->shokushu_id) {
$user_search['user_shokushus'] = unserialize($user_search->shokushu_id);
}
if ($user_search->kinmuchi_id) {
$user_search['user_kinmuchis'] = unserialize($user_search->kinmuchi_id);
}
if ($user_search->keitai_id) {
$user_search['user_keitais'] = unserialize($user_search->keitai_id);
}
if ($user_search->category_id) {
$user_search['user_categories'] = unserialize($user_search->category_id);
}
}
$shokushus = Shokushu::get();
$kinmuchis = Kinmuchi::get();
$keitais = Keitai::orderBy('sort_order', 'asc')->get();
$categories = Category::orderBy('sort_order', 'asc')->get();
// return $user_searches;
return view('my.list_search_condition', ['user_searches' => $user_searches, 'shokushus' => $shokushus, 'kinmuchis' => $kinmuchis, 'keitais' => $keitais, 'categories' => $categories]);
}
示例14: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$categories = Category::orderBy('id', 'ASC')->paginate(15);
return view('admin/categories/index')->with('categories', $categories);
}
示例15: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$categories = Category::orderBy('is_active', 'asc')->orderBy('created_at', 'desc')->paginate($this->itemPerPage);
return view('redac.categories.index', compact('categories'));
}