add latest news item as widget to dashboard #52

This commit is contained in:
Nabeel Shahzad
2018-01-10 16:02:33 -06:00
parent 2f33c7b6aa
commit 2ccaaddfcd
4 changed files with 48 additions and 11 deletions

View File

@@ -0,0 +1,25 @@
<?php
namespace App\Widgets;
use App\Repositories\NewsRepository;
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']),
]);
}
}