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


PHP News::orderBy方法代码示例

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


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

示例1: index

 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index()
 {
     $banners = Banner::where('active', 'Y')->orderBy('id', 'desc')->get();
     $news = News::orderBy('date', 'desc')->take(5)->get();
     $videos = Video::orderBy('id', 'desc')->take(5)->get();
     return view('home', compact('banners', 'news', 'videos'));
 }
开发者ID:RelmekTaiwan,项目名称:sebamed,代码行数:12,代码来源:HomeController.php

示例2: index

 public function index($local = 'fa')
 {
     App::setLocale($local);
     $news = News::orderBy('id', 'Desc')->take(4)->get();
     //dd($news);
     return view('main.index', compact('news'));
 }
开发者ID:slifer2015,项目名称:tarabar,代码行数:7,代码来源:IndexController.php

示例3: boot

 public function boot()
 {
     // validator for alphabetic characters and spaces http://blog.elenakolevska.com/laravel-alpha-validator-that-allows-spaces/
     // It matches unicode characters, so even João Gabriel won't have his name marked as invalid anymore :)
     Validator::extend('alpha_spaces', function ($attribute, $value, $parameters, $validator) {
         return preg_match('/^[\\pL\\s]+$/u', $value);
     });
     // элементы шаблона сайта
     view()->composer('modules.topmenu', function ($view) {
         $view->withTree(Category::descendantsOf(1)->toTree());
     });
     view()->composer('modules.mainmenu', function ($view) {
         $view->withTree(Category::descendantsOf(1)->toTree());
     });
     view()->composer('modules.breadcrumbs', function ($view) {
         $urlarr = explode('?', $_SERVER['REQUEST_URI']);
         // получаем массив сегментов URI без ?
         $urlget = array_shift($urlarr);
         // получаем первый элемент до ?
         $urllist = explode('/', $urlget);
         // получаем массив сегментов URI без слеша
         $lastbread = array_pop($urllist);
         // получаем последний элемент массива (после последнего слеша)
         $view->withLastbread($lastbread);
     });
     view()->composer('modules.popular', function ($view) {
         $view->withPopular(Link::orderBy('hits', 'desc')->take(5)->get());
     });
     view()->composer('modules.lastnews', function ($view) {
         $view->withLastnews(News::orderBy('created_at', 'desc')->take(5)->get());
     });
 }
开发者ID:schel4ok,项目名称:steklo,代码行数:32,代码来源:AppServiceProvider.php

示例4: news

 public function news(Request $request)
 {
     if ($request->isMethod('POST')) {
         //            News::create($request->except('_token'));
         // read image from temporary file
         $file = $request->file('imagePrev');
         $img = Image::make($file->getRealPath());
         $nameFile = $file->getClientOriginalName();
         //          resize image
         $img->fit(263, 263);
         // save image
         $img->save("images/" . $nameFile);
         News::create(['text' => $request->input('editor1'), 'header' => $request->input('header'), 'picture' => "images/" . $nameFile]);
         //            switch ( $request->input('type') ) {
         //                case 'insert':
         //                    News::create($request->except('_token'));
         //                    break;
         //                case 'update':
         //                    News::find( $request->input('id') )->update([
         //                        'header' => $request->input('header'),
         //                        'text' => $request->input('editor1'),
         //                    ]);
         //                    break;
         //            }
     }
     if ($request->isMethod('GET')) {
         $item = News::find($request->input('remove'));
         if ($item) {
             $item->delete();
         }
     }
     $news = News::orderBy('created_at', 'DESC')->paginate(15);
     return view('admin/news', ['news' => $news]);
 }
开发者ID:GraninNikita,项目名称:feo,代码行数:34,代码来源:AdminController.php

示例5: store

 /**
  * @param \App\Http\Requests\CreateNewsRequest $request
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function store(CreateNewsRequest $request)
 {
     News::create($request->all());
     $news = News::orderBy('updated_at', 'desc')->get();
     session()->flash('flash_message', 'Je artikel is succesvol toegevoegd');
     return view('news.index', compact('news'));
 }
开发者ID:jordygroote,项目名称:detoekomstapp,代码行数:11,代码来源:NewsController.php

示例6: getIndex

 public function getIndex()
 {
     $category = Category::where('type', '=', 'news')->first();
     $news = News::orderBy('created_at', 'desc')->paginate(10);
     // все новости по 10 штук на страницу
     return view('news.index')->withNews($news)->withCategory($category);
 }
开发者ID:schel4ok,项目名称:steklo,代码行数:7,代码来源:NewsController.php

示例7: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show(News $news)
 {
     $news->increment('dibaca');
     $comments = Comments::orderBy('created_at', 'DESC')->get()->where('news_id', $news->id);
     $sidebar = $news->orderBy('dibaca', 'DESC')->limit(5)->get();
     $otherposts = News::orderBy('created_at', 'DESC')->where('kategori_id', $news->kategori_id)->limit(3)->get();
     return view('sowindows.show', compact(['news', 'otherposts', 'comments', 'sidebar']));
 }
开发者ID:ranugoldan,项目名称:SoWindows,代码行数:14,代码来源:HomeController.php

示例8: getIndex

 /**
  * Отображает список новостей.
  *
  * @return \Illuminate\Http\Response
  */
 public function getIndex()
 {
     // Статья с описанием новостей
     Model::unguard();
     $data['news_description'] = Article::firstOrCreate(['type' => 'news_description']);
     Model::reguard();
     $data['news'] = News::orderBy('created_at', 'DESC')->paginate(4);
     return view('marketing.news.index', $data);
 }
开发者ID:alexmon1989,项目名称:kadsgroup,代码行数:14,代码来源:NewsController.php

示例9: home

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function home()
 {
     $lastNews = News::orderBy('id', 'desc')->first();
     $lastNews->description = $this::text_humanized($lastNews->description);
     Date::setLocale('fr');
     $date = new Date($lastNews->when);
     $lastNews->when = $date->format('l j F Y');
     $lastNews->hour = $date->format('H:i');
     return view('page/home', ['news' => $lastNews]);
 }
开发者ID:AxelCardinaels,项目名称:CbSeraing-Laravel,代码行数:15,代码来源:PagesController.php

示例10: homepage

 public function homepage()
 {
     $user = Auth::user() ?: false;
     $cars = Car::with('inquiriesCount')->orderBy('domestic', 'asc')->orderBy('name')->get();
     $cars1 = $cars->filter(function ($item) {
         return $item->name == "ВАЗ";
     });
     $cars2 = $cars->filter(function ($item) {
         return $item->name != "ВАЗ";
     });
     $cars = $cars1->merge($cars2);
     $carsList = $cars->lists('name', 'id')->toArray();
     $lastInquiries = Inquiry::with('car', 'city')->orderBy('created_at', 'desc')->paginate(config('vars.inquiries_per_page'));
     $lastInquiries->setPath('inquiry/index');
     Carbon::setLocale(config('app.locale'));
     $lastNews = News::orderBy('published_at', 'desc')->paginate(config('vars.news_per_page'));
     $lastNews->setPath('news/index');
     $cities = City::lists('name', 'id')->all();
     $blocks = Block::all()->keyBy('alias');
     $faq = Faq::all();
     return view('homepage', compact('user', 'cars', 'carsList', 'lastInquiries', 'lastNews', 'cities', 'blocks', 'faq'));
 }
开发者ID:jambik,项目名称:sellmecar,代码行数:22,代码来源:HomepageController.php

示例11: getLatestNews

 public function getLatestNews()
 {
     return News::orderBy('published_at', 'desc')->where('published_at', '<=', Carbon::now())->get();
 }
开发者ID:Andrew261,项目名称:filolog,代码行数:4,代码来源:News.php

示例12: adminIndex

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function adminIndex()
 {
     $news = News::orderBy('published_at', 'desc')->with('author')->paginate(5);
     return view('admin.news.index', compact('news'));
 }
开发者ID:Techraav,项目名称:PolyMusic,代码行数:10,代码来源:NewsController.php

示例13: news

 public function news()
 {
     $news = News::orderBy('date', 'desc')->get();
     $this->data['news'] = $news;
     return view('public.news', $this->data);
 }
开发者ID:nosari20,项目名称:ascii,代码行数:6,代码来源:HomeController.php

示例14: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $data['news'] = News::orderBy('created_at', 'desc')->get();
     return view('admin.news', $data);
 }
开发者ID:nikajorjika,项目名称:gamoiwere.ge,代码行数:10,代码来源:NewsController.php

示例15: getNews

 public function getNews()
 {
     return view('news')->with(['news' => News::orderBy('time', 'desc')->where('defunct', 'N')->paginate(50)]);
 }
开发者ID:fuzhongqing,项目名称:newoj,代码行数:4,代码来源:HomeController.php


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