本文整理汇总了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'));
}
示例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'));
}
示例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());
});
}
示例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]);
}
示例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'));
}
示例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);
}
示例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']));
}
示例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);
}
示例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]);
}
示例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'));
}
示例11: getLatestNews
public function getLatestNews()
{
return News::orderBy('published_at', 'desc')->where('published_at', '<=', Carbon::now())->get();
}
示例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'));
}
示例13: news
public function news()
{
$news = News::orderBy('date', 'desc')->get();
$this->data['news'] = $news;
return view('public.news', $this->data);
}
示例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);
}
示例15: getNews
public function getNews()
{
return view('news')->with(['news' => News::orderBy('time', 'desc')->where('defunct', 'N')->paginate(50)]);
}