add and delete news from admin dashboard #52

This commit is contained in:
Nabeel Shahzad
2018-01-08 16:22:26 -06:00
parent 5a12493739
commit 6b265ed67b
10 changed files with 149 additions and 21 deletions

View File

@@ -1,9 +0,0 @@
<div class="card border-blue-bottom">
<div class="header">
<h4 class="title">Announcements</h4>
<p class="category">just updated</p>
</div>
<div class="content">
blah blah blah
</div>
</div>

View File

@@ -5,7 +5,7 @@
<div class="row">
<div class="col-md-7">
@include('admin.dashboard.announcements')
@include('admin.dashboard.news')
</div>
<div class="col-md-5">
@component('admin.components.infobox')
@@ -43,4 +43,17 @@
</div>
</div>
@endsection
@section('scripts')
<script>
$(document).ready(function() {
$(document).on('submit', 'form.pjax_news_form', function (event) {
event.preventDefault();
$.pjax.submit(event, '#pjax_news_wrapper', {push: false});
});
/*$(document).on('pjax:complete', function () {
$(".select2").select2();
});*/
});
</script>
@endsection

View File

@@ -0,0 +1,64 @@
<div id="pjax_news_wrapper">
<div class="card border-blue-bottom">
@if($news->count() === 0)
<div class="text-center text-muted" style="padding: 30px;">
no news items
</div>
@endif
@foreach($news as $item)
<div class="content">
<div class="header">
<h4 class="title">{!! $item->subject !!}</h4>
<p class="category">{!! $item->user->name !!} - {!! show_datetime($item->created_at) !!}</p>
</div>
{!! $item->body !!}
<div class="text-right">
{!! Form::open(['route' => 'admin.dashboard.news',
'method' => 'delete',
'class' => 'pjax_news_form',
]) !!}
{!! Form::hidden('news_id', $item->id) !!}
{!!
Form::button('delete',
['type' => 'submit',
'class' => ' btn btn-danger btn-xs text-small'])
!!}
{!! Form::close() !!}
</div>
</div>
<hr />
@endforeach
<div class="content">
<div class="header">
<h4 class="title">Add News</h4>
</div>
{!! Form::open(['route' => 'admin.dashboard.news',
'method' => 'post',
'class' => 'pjax_news_form',
]) !!}
<table class="table">
<tr>
<td>{!! Form::label('subject', 'Subject:') !!}</td>
<td>{!! Form::text('subject', '', ['class' => 'form-control']) !!}</td>
</tr>
<tr>
<td>{!! Form::label('body', 'Body:') !!}</td>
<td>{!! Form::textarea('body', '', ['class' => 'form-control']) !!}</td>
</tr>
</table>
<div class="text-right">
{!!
Form::button('<i class="glyphicon glyphicon-plus"></i> add',
['type' => 'submit',
'class' => 'btn btn-success btn-s'])
!!}
{!! Form::close() !!}
</div>
</div>
</div>
</div>