2018-01-11 06:02:33 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Widgets;
|
|
|
|
|
|
|
|
use App\Repositories\NewsRepository;
|
|
|
|
|
2018-02-21 12:33:09 +08:00
|
|
|
/**
|
|
|
|
* Show the latest news in a view
|
|
|
|
* @package App\Widgets
|
|
|
|
*/
|
2018-01-11 06:02:33 +08:00
|
|
|
class LatestNews extends BaseWidget
|
|
|
|
{
|
|
|
|
protected $config = [
|
|
|
|
'count' => 5,
|
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
|
|
|
*/
|
|
|
|
public function run()
|
|
|
|
{
|
|
|
|
$newsRepo = app(NewsRepository::class);
|
|
|
|
|
|
|
|
return $this->view('widgets.latest_news', [
|
|
|
|
'config' => $this->config,
|
|
|
|
'news' => $newsRepo->recent($this->config['count']),
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|