2018-01-11 06:02:33 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Widgets;
|
|
|
|
|
2018-03-20 09:50:40 +08:00
|
|
|
use App\Interfaces\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,
|
2018-03-20 09:50:40 +08:00
|
|
|
'news' => $newsRepo->recent($this->config['count']),
|
2018-01-11 06:02:33 +08:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|