當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。