add latest news item as widget to dashboard #52
This commit is contained in:
parent
2f33c7b6aa
commit
2ccaaddfcd
@ -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']),
|
||||
]);
|
||||
}
|
||||
}
|
@ -57,17 +57,7 @@
|
||||
@include('layouts.default.pireps.pirep_card', ['pirep' => $last_pirep])
|
||||
@endif
|
||||
|
||||
<div class="card">
|
||||
<div class="nav nav-tabs" role="tablist" style="background: #067ec1; color: #FFF;">
|
||||
News
|
||||
</div>
|
||||
<div class="card-block">
|
||||
<!-- Tab panes -->
|
||||
<div class="tab-content">
|
||||
News goes here!
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{ Widget::latestNews(['count' => 1]) }}
|
||||
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
|
@ -0,0 +1,20 @@
|
||||
<div class="nav nav-tabs" role="tablist" style="background: #067ec1; color: #FFF;">
|
||||
News
|
||||
</div>
|
||||
<div class="card border-blue-bottom">
|
||||
<div class="card-block" style="min-height: 0px">
|
||||
@if($news->count() === 0)
|
||||
<div class="text-center text-muted" style="padding: 30px;">
|
||||
no news items
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@foreach($news as $item)
|
||||
<h4 style="margin-top: 0px;">{!! $item->subject !!}</h4>
|
||||
<p class="category">{!! $item->user->name !!}
|
||||
- {!! show_datetime($item->created_at) !!}</p>
|
||||
|
||||
{!! $item->body !!}
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user