本文整理汇总了PHP中app\News::all方法的典型用法代码示例。如果您正苦于以下问题:PHP News::all方法的具体用法?PHP News::all怎么用?PHP News::all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\News
的用法示例。
在下文中一共展示了News::all方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
//
$news = News::all();
$auth = User::all();
return view('backend.pages.news.listNews', array('news' => $news, 'auth' => $auth));
}
示例2: index
/**
* Display a listing of the news articles.
*
* @return Response
*/
public function index()
{
// get all
$news = News::all();
// set response as json with data
return Response()->json(['data' => $news, 'code' => 200], 200);
}
示例3: news
public function news($page)
{
Carbon::setLocale('nl');
$posts = News::all()->count();
$pages = ceil($posts / 3);
if ($page > $pages) {
return redirect('nieuws/pagina-1');
}
$news = News::latest()->skip(($page - 1) * 3)->take(3)->get();
return view('pages.public.news')->with(['news' => $news, 'page' => $page, 'pages' => $pages]);
}
示例4: getAdminPanel
public function getAdminPanel()
{
$pageName = 'Dashboard';
$users = Sentry::findAllUsers();
$newUsers = new Collection($users);
$userNumber = $newUsers->count();
$propertyNumber = Property::all()->count();
$soldPropertyNumber = Property::where('state', '=', 'sold')->count();
$newsNumber = News::all()->count();
return view('admin.adminIndex')->with(compact('pageName', 'userNumber', 'propertyNumber', 'soldPropertyNumber', 'newsNumber'));
}
示例5: showNewsAction
public function showNewsAction()
{
if (!Request::has('page_number')) {
$page_number = 1;
} else {
$page_number = Request::input('page_number');
}
$news = News::latest('created_at')->skip(($page_number - 1) * 5)->take(5)->get();
$news_amount = count(News::all());
return view('base.news', ['news' => $news, 'page_number' => $page_number, 'news_amount' => $news_amount]);
}
示例6: index
public function index()
{
$totalNumber = 5;
// number of items to take for each section
$data = ["events" => Event::where('end_datetime', '>', date(time()))->get()->take($totalNumber), "partners" => Partner::all()->take($totalNumber), "news" => News::all()->take($totalNumber), "media" => Media::where('processed', 0)->get()->take($totalNumber * 2)->chunk(3), "staffs" => User::where('is_staff', 1)->get(), "locations" => Location::all()->take($totalNumber)];
$i = 0;
foreach ($data['events'] as $event) {
$mediaCount = count(Media::where('processed', false)->where('event_id', $event->id)->get());
$data['events'][$i]->mediaCount = $mediaCount;
$i++;
}
return View::make('admin.index')->with($data);
}
示例7: getAbout
public function getAbout(Request $request)
{
if ($request->input('id') == null) {
$news = News::all();
$about = About::first();
return view('home.about')->with(['news' => $news, 'about' => $about]);
} else {
$item = News::where('id', $request->input('id'))->first();
if ($item == null) {
return redirect('about');
}
return view('home.news')->with('item', $item);
}
}
示例8: v1News
/**
* http://wiki.atlauncher.com/api:news
*
* @return Response
*/
public function v1News()
{
$data = array();
$i = 0;
foreach (News::all() as $item) {
if ($i >= 10) {
break;
}
$dt = new DateTime($item->published_at);
$data[$i] = array("title" => $item->title, "comments" => $item->comments, "link" => $item->link, "published_at" => $dt->format('U'), "content" => $item->content);
$i++;
}
return Response::make(json_encode(array("error" => false, "code" => 200, "message" => null, "data" => $data), JSON_PRETTY_PRINT))->header('Content-Type', "application/json");
}
示例9: index
public function index($sort = 'departure')
{
$this->page->title = 'Заказы такси';
$this->page->desc = 'Текущие заказы';
$this->data['sort'] = $sort;
if (Sentinel::inRole('admin')) {
// АДМИНИСТРАТОР Новые и редактированные заказы
$this->data['orders_new'] = Order::whereIn('order_status', array(1, 2))->orderBy('updated_at', 'desc')->get();
// АДМИНИСТРАТОР Текущие заказы
if ($sort == 'arrivals') {
// Сортировка по прилету
$this->data['orders'] = Order::whereRaw('order_status = 3 AND (departure_time > now() OR arrivals_time > now())')->orderBy('arrivals_time')->get();
} else {
// Сортировка по вылету
$this->data['orders'] = Order::whereRaw('order_status = 3 AND (departure_time > now() OR arrivals_time > now())')->orderBy('departure_time')->get();
}
// не олачено
$this->data['nopay_orders'] = Order::whereRaw('order_status = 3 AND payment_status = 0 AND (departure_time < now() and arrivals_time < now())')->orderBy('departure_time')->get();
$news = News::all();
// \Session::flash('messages', count($news));
foreach ($news as $key => $val) {
\Session::flash('flash_message_' . $key, $val->body);
}
// АДМИНИСТРАТОР отображение
return $this->render('order.list-admin');
} else {
// ПОЛЬЗОВАТЕЛЬ Текущие заказы
$this->data['orders'] = Order::whereRaw('user_id = ' . $this->user->id . ' AND (departure_time > now() OR arrivals_time > now())')->orderBy('created_at', 'DESC')->get();
// не олачено
$this->data['nopay_orders'] = Order::whereRaw('user_id = ' . $this->user->id . ' AND payment_status = 0 AND (departure_time < now() AND arrivals_time < now())')->orderBy('created_at', 'DESC')->get();
$news = News::all();
// \Session::flash('messages', count($news));
foreach ($news as $key => $val) {
\Session::flash('flash_message_' . $key, $val->body);
}
// ПОЛЬЗОВАТЕЛЬ отображение
return $this->render('order.list-user');
}
}
示例10: getIndex
/**
* Отображает карту сайта в нужном формате формате.
*
* @return \Illuminate\Http\Response
*/
public function getIndex($format = 'xml', $cached = true)
{
// Проверка формата вывода данных
if (!in_array($format, ['xml', 'html', 'txt', 'ror-rss', 'ror-rdf'])) {
abort(404);
}
// Объект карты сайта
$sitemap = App::make('sitemap');
// Кэш карты сайта
$sitemap->setCache('laravel.sitemap', 3600, (bool) $cached);
// Проверка закеширована ли карта сайта, если нет - "строим" заново
if (!$sitemap->isCached()) {
// Добавление страниц с постоянными ссылками
$sitemap->add(URL::to('/'));
$sitemap->add(URL::to('companies/sika/about'));
$sitemap->add(URL::to('companies/sika/catalog'));
$sitemap->add(URL::to('companies/sfs/about'));
$sitemap->add(URL::to('companies/sfs/catalog'));
//$sitemap->add(URL::to('companies/sfs/videos'));
$sitemap->add(URL::to('companies/primer/about'));
$sitemap->add(URL::to('companies/primer/catalog'));
//$sitemap->add(URL::to('companies/primer/videos'));
$sitemap->add(URL::to('companies/primer/price-list'));
// Добавление страниц групп категорий и категорий всех трёх компаний
foreach (['sika', 'sfs', 'primer'] as $company) {
$groupCategories = GroupsCategory::whereEnabled(TRUE)->with(['categories' => function ($q) {
$f = function ($q) {
$q->whereEnabled(TRUE);
};
$q->whereEnabled(TRUE)->with(['products_sika' => $f, 'products_sfs' => $f, 'products_primer' => $f]);
}])->whereHas('company', function ($q) use($company) {
$q->whereShortTitle($company);
})->get();
// Проходим по группам категорий
foreach ($groupCategories as $groupCategory) {
// Добавление группы категорий
$sitemap->add(URL::to("companies/{$company}/catalog/group/{$groupCategory->id}"));
// Добавление категории
foreach ($groupCategory->categories as $category) {
$sitemap->add(URL::to("companies/{$company}/catalog/category/{$category->id}"));
// Добавление товаров для каждой категории
foreach ($category->products_sika as $productSika) {
// Ссылка на страницу продукта
$sitemap->add(URL::to("companies/{$company}/catalog/show/{$productSika->id}"));
// Ссылка на техкарту
//$sitemap->add(URL::to("assets/img/products/{$company}/tech-carts/{$productSika->tech_cart_file}"));
}
foreach ($category->products_sfs as $productSfs) {
// Ссылка на страницу продукта
$sitemap->add(URL::to("companies/{$company}/catalog/show/{$productSfs->id}"));
// Ссылка на pdf
//$sitemap->add(URL::to("assets/img/products/{$company}/pdf/{$productSfs->file_name}"));
}
foreach ($category->products_primer as $productPrimer) {
$sitemap->add(URL::to("companies/{$company}/catalog/show/{$productPrimer->id}"));
}
}
}
// Галереи
/*$galleryImages = Gallery::whereHas('company', function ($query) use ($company) {
$query->whereShortTitle($company);
})->get();
$images = []; // Массив описаний изображений для Sitemap
foreach($galleryImages as $image) {
$images[] = [
'url' => URL::to('assets/img/galleries/'.$image->file_name),
'title' => $image->title,
];
}
$sitemap->add(URL::to("galleries/show/{$company}"), null, null, null, $images);*/
}
/*$certificates = Certificate::all();
$imagesCertificates = []; // Массив описаний изображений для сертификатов
foreach($certificates as $certificate) {
$imagesCertificates[] = [
'url' => URL::to('assets/img/certificates/'.$certificate->file_name),
'title' => $certificate->title,
];
}
$sitemap->add(URL::to('certificates'), null, null, null, $imagesCertificates);*/
$sitemap->add(URL::to('news'));
// Добавляем все статьи новостей
$news = News::all();
foreach ($news as $item) {
$sitemap->add(URL::to('news/show/' . $item->id));
}
$sitemap->add(URL::to('contacts'));
}
// Отображение карты сайта
return $sitemap->render($format);
}
示例11: index
/**
* Display a listing of news
*
* @param Request $request
*
* @return \Illuminate\View\View
*/
public function index(Request $request)
{
$news = News::all();
return view('admin.news.index', compact('news'));
}
示例12: function
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Storage;
use App\News;
// Meta
$app->get('/meta', function () {
$ships = json_decode(Storage::disk('local')->get('api_ships.json'), false)->results;
$maps = json_decode(Storage::disk('local')->get('api_maps.json'), false)->results;
$equips = json_decode(Storage::disk('local')->get('api_equips.json'), false)->results;
return view('meta')->withShips($ships)->withMaps($maps)->withEquips($equips);
});
// API
$app->get('/news', function () {
$news = News::all();
return response()->json($news);
});
$app->post('/news', function (Request $request) {
if (!Auth::check()) {
return redirect('/login');
}
$rules = ['title' => 'required|max:256', 'ship' => 'array', 'quest' => 'array', 'content' => 'max:1024', 'equip' => 'array'];
$validator = Validator::make($request->all(), $rules);
if ($validator->fails()) {
return redirect('/')->withErrors($validator);
}
$ship = $request->input('ship') ? join(',', $request->input('ship')) : '';
$quest = $request->input('quest') ? join(',', $request->input('quest')) : '';
$equip = $request->input('equip') ? join(',', $request->input('equip')) : '';
News::create(['title' => $request->input('title'), 'ship' => $ship, 'equip' => $equip, 'quest' => $quest, 'content' => $request->input('content')]);
示例13: postDeleteNews
public function postDeleteNews($id)
{
$news = News::findOrFail($id);
$news->delete(News::all());
return redirect('nieuws');
}
示例14: getIndex
/**
* Отображает список новостей
*
* @return Response
*/
public function getIndex()
{
$data['news'] = News::all();
return view('admin.news.index', $data);
}
示例15: index
public function index()
{
$news = News::all();
$news = News::paginate(3);
return View::make('admin.admin-editor')->with('news', $news);
}