add latest news item as widget to dashboard #52
This commit is contained in:
@@ -12,6 +12,8 @@ use Arrilot\Widgets\AbstractWidget;
|
||||
|
||||
class BaseWidget extends AbstractWidget
|
||||
{
|
||||
public $cacheTime = 0;
|
||||
|
||||
public function view(string $template, array $vars = [])
|
||||
{
|
||||
$tpl = 'layouts/' . config('phpvms.skin') . '/' . $template;
|
||||
|
||||
25
app/Widgets/LatestNews.php
Normal file
25
app/Widgets/LatestNews.php
Normal 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']),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user