本文整理汇总了PHP中app\Category::orderBy方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::orderBy方法的具体用法?PHP Category::orderBy怎么用?PHP Category::orderBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Category
的用法示例。
在下文中一共展示了Category::orderBy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
// obtnemos las categorias
$categories = Category::orderBy('id', 'ASC')->paginate(5);
// le enviamos las categorias
return view('admin.categories.index')->with('categories', $categories);
}
示例2: index
public function index()
{
//get all the categories
$categories = Category::orderBy("category_id", "ASC")->paginate(20);
//load the view and pass the categories
return view('categories.index')->with('categories', $categories);
}
示例3: compose
public function compose(View $view)
{
$tags = Tag::orderBy('id', 'DESC')->get();
$categories = Category::orderBy('id', 'DESC')->simplepaginate(7);
$images = Image::orderBy('id', 'DESC')->paginate(4);
$view->with('tags', $tags)->with('categories', $categories)->with('images', $images);
}
示例4: camposEdicion
public function camposEdicion($id)
{
$product = null;
if ($id != null) {
$product = Product::findOrFail($id);
}
$categories = Category::orderBy('name', 'asc')->get();
$arrayCat = null;
$arrayCol = null;
$checked = null;
foreach ($categories as $cat) {
$arrayCat[$cat->id] = $cat->name;
}
$colors = Color::orderBy('name', 'asc')->get();
foreach ($colors as $col) {
$arrayCol[$col->id] = ['name' => $col->name, 'checked' => ""];
if (isset($product)) {
$checkColor = ProductColor::where('id_product', $product->id)->where('id_color', $col->id)->count();
if ($checkColor > 0) {
$arrayCol[$col->id]['checked'] = "checked";
}
}
}
return ['arrayCat' => $arrayCat, 'colors' => $arrayCol, 'product' => $product];
}
示例5: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$cities = City::all();
// Grab all the cities and then do a for each.
// run this for each of them.
foreach ($cities as $city) {
$events = Event::where('city_id', '=', $city->id)->where('time_end', '>=', date('Y-m-d H:i:s'))->where('time_end', '<=', date('Y-m-d H:i:s', strtotime('+2 weeks')))->orderBy('time_start', 'asc')->get();
if (!count($events)) {
$this->comment('No events found for ' . $city->name . '. Mailer not sent.');
continue;
}
$categories = Category::orderBy('title', 'asc')->get();
if ($this->option('email')) {
$subscriber = new Subscriber();
$subscriber->name = 'Test User';
$subscriber->email = $this->option('email');
$subscribers = [$subscriber];
$this->comment('Sent test email to ' . $this->option('email'));
} else {
$subscribers = Subscriber::where('city_id', '=', $city->id)->get();
}
$count = 0;
foreach ($subscribers as $subscriber) {
Mail::send('emails.subscribers.mailer', ['subscriber' => $subscriber, 'events' => $events, 'categories' => $categories, 'city' => $city], function ($m) use($subscriber, $city) {
$m->from('messages@madebyfieldwork.com', 'See+Do')->to($subscriber->email, $subscriber->name)->subject('Weekly Round-Up of Things to See+Do in ' . $city->name)->getHeaders()->addTextHeader('X-MC-Subaccount', 'see-do');
});
$count++;
}
$this->comment('Sent to ' . $count . ' email addresses in ' . $city->name . '.');
$count = 0;
}
}
示例6: compose
public function compose(View $view)
{
$categories = Cache::remember('categories', 1440, function () {
return Category::orderBy('name')->get();
});
$view->with(['user' => $this->auth->user(), 'categories' => $categories, 'guest' => !$this->auth->check()]);
}
示例7: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
$article = Article::find($id);
$categories = Category::orderBy('name', 'DESC')->lists('name', 'id');
$tags = Tag::orderBy('name', 'DESC')->lists('name', 'id');
$my_tags = $article->tags->lists('id')->toArray();
return view('admin.articles.edit')->with('categories', $categories)->with('tags', $tags)->with('article', $article)->with('my_tags', $my_tags);
}
示例8: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
$service = Service::findOrFail($id);
$currencies = ['hrk' => 'HRK', 'usd' => 'USD', 'eur' => 'EUR'];
$clients = Client::orderBy('name')->pluck('name', 'id')->toArray();
$categories = Category::orderBy('name')->pluck('name', 'id')->toArray();
return view('services.edit')->with(compact('service', 'currencies', 'clients', 'categories'));
}
示例9: 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();
}
示例10: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$pages = Category::orderBy('parent_id', 'ASC')->orderBy('category_order', 'ASC')->get()->toArray();
$Tree = new Tree();
$tree = $Tree->buildTree($pages);
list($keys, $values) = array_divide($tree);
return $values;
}
示例11: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$articles = Article::OrderBy('id', 'DESC')->paginate(7);
$categories = Category::orderBy('name', 'ASC')->get();
$tags = Tag::orderBy('name', 'ASC')->get();
$images = Image::orderBy('article_id', 'DESC')->get();
return view('admin.index')->with('articles', $articles)->with('tags', $tags)->with('images', $images)->with('categories', $categories);
}
示例12: boot
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
$categories = [];
if (Schema::hasTable('categories')) {
$categories = App\Category::orderBy('name')->get();
}
view()->share(compact('categories'));
}
示例13: edit
public function edit($id)
{
$post = Post::where('id', $id)->first();
$categories = Category::orderBy('name')->get();
if (empty($post)) {
return Redirect::route('administration.index');
}
return view('administration.blog.edit', ['post' => $post, 'categories' => $categories]);
}
示例14: edit
public function edit($id)
{
$article = Article::find($id);
$article->category;
$categories = Category::orderBy('name', 'DESC')->lists('name', 'id');
$tags = Tag::orderBy('name', 'DESC')->lists('name', 'id');
$my_tags = $article->tags->lists('id')->ToArray();
return view('admin.articles.edit')->with(['categories' => $categories, 'article' => $article, 'tags' => $tags, 'my_tags' => $my_tags]);
}
示例15: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$categories = Category::orderBy('order')->get()->toArray();
foreach ($categories as &$c) {
$c['action'] = array('create' => Config::get('app.url') . '/category/' . $c['id'] . '/posts/create', 'view' => Config::get('app.url') . '/category/' . $c['id'] . '/posts');
}
$index = new Collection();
$index['data'] = $categories;
return response()->json($index);
}