2018-01-11 06:02:33 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Widgets;
|
|
|
|
|
2019-07-16 03:44:31 +08:00
|
|
|
use App\Contracts\Widget;
|
2018-01-11 06:02:33 +08:00
|
|
|
use App\Repositories\NewsRepository;
|
|
|
|
|
2018-02-21 12:33:09 +08:00
|
|
|
/**
|
|
|
|
* Show the latest news in a view
|
|
|
|
*/
|
2018-03-20 09:50:40 +08:00
|
|
|
class LatestNews extends Widget
|
2018-01-11 06:02:33 +08:00
|
|
|
{
|
|
|
|
protected $config = [
|
|
|
|
'count' => 5,
|
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
|
|
|
*/
|
|
|
|
public function run()
|
|
|
|
{
|
|
|
|
$newsRepo = app(NewsRepository::class);
|
|
|
|
|
2018-03-12 07:00:42 +08:00
|
|
|
return view('widgets.latest_news', [
|
2018-01-11 06:02:33 +08:00
|
|
|
'config' => $this->config,
|
Eager loading update for frontend controllers and widgets (#1348)
* Update AirportController.php
Eager load `files`
* Update DashboardController.php
Eager load `journal` for user , and `aircraft, arr_airport, comments, dpt_airport` for last_pirep.
* Update FlightController.php
Eager load + `alt_airport, subfleets` (with their airlines) for flights and `current_airport` for user
(though current_airport can be removed and we can base the in blade checks on `$user->curr_airport_id` to reduce db reads and model loading)
* Update HomeController.php
Eager load `home_airport` for users
* Update PirepController.php
Eager load `airline, aircraft, fares, transactions, dpt_airport, arr_airport, comments, simbrief, user with rank` for pirep details
* Update ProfileController.php
Eager load `airline, awards, current_airport, fields.field, home_airport, last_pirep, rank` for user
* Update UserController.php
Eager load `airline, current_airport, fields.field, home_airport, rank` for users and count `awards`
* Update AirportController.php
* Update DashboardController.php
* Update PirepController.php
* Update ProfileController.php
* Update LatestNews.php
Eager load `user` for news
* Update LatestPilots.php
Eager load `home_airport` for latest users
* StyleFix 1
* StlyeFix 1.5
* Update SimBriefController.php
Eager load airline with flight
* Update SimBriefController.php
* Update SimBriefController.php
2021-11-09 22:51:02 +08:00
|
|
|
'news' => $newsRepo->with('user')->recent($this->config['count']),
|
2018-01-11 06:02:33 +08:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|