diff --git a/app/Widgets/BaseWidget.php b/app/Widgets/BaseWidget.php index f039f748..57436b4c 100644 --- a/app/Widgets/BaseWidget.php +++ b/app/Widgets/BaseWidget.php @@ -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; diff --git a/app/Widgets/LatestNews.php b/app/Widgets/LatestNews.php new file mode 100644 index 00000000..74ef9123 --- /dev/null +++ b/app/Widgets/LatestNews.php @@ -0,0 +1,25 @@ + 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']), + ]); + } +} diff --git a/resources/views/layouts/default/dashboard/index.blade.php b/resources/views/layouts/default/dashboard/index.blade.php index 9a98ca6f..6a7c2462 100644 --- a/resources/views/layouts/default/dashboard/index.blade.php +++ b/resources/views/layouts/default/dashboard/index.blade.php @@ -57,17 +57,7 @@ @include('layouts.default.pireps.pirep_card', ['pirep' => $last_pirep]) @endif -
- -
- -
- News goes here! -
-
-
+ {{ Widget::latestNews(['count' => 1]) }}
diff --git a/resources/views/layouts/default/widgets/latest_news.blade.php b/resources/views/layouts/default/widgets/latest_news.blade.php new file mode 100644 index 00000000..0d9c0757 --- /dev/null +++ b/resources/views/layouts/default/widgets/latest_news.blade.php @@ -0,0 +1,20 @@ + +
+
+ @if($news->count() === 0) +
+ no news items +
+ @endif + + @foreach($news as $item) +

{!! $item->subject !!}

+

{!! $item->user->name !!} + - {!! show_datetime($item->created_at) !!}

+ + {!! $item->body !!} + @endforeach +
+