diff --git a/app/Http/Controllers/PostsController.php b/app/Http/Controllers/PostsController.php index 7beb64e2138ea7ae5f980d18ffeab71d7453d1e3..7e8c1a9549bba5ccc888adfd7bea13308984165d 100644 --- a/app/Http/Controllers/PostsController.php +++ b/app/Http/Controllers/PostsController.php @@ -53,6 +53,16 @@ class PostsController extends Controller 'cover_image' => 'image|nullable|max:1999' ]); + $public = '0'; + $draft = '0'; + if ($request->input('draft') === 'yes') { + $draft = '1'; + } + + if ($request->input('public') === 'yes') { + $public = '1'; + } + if ($request->hasFile('cover_image')) { $filenameWithExt = $request->file('cover_image')->getClientOriginalName(); $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME); @@ -66,6 +76,8 @@ class PostsController extends Controller $post = new Post; $post->title = $request->input('title'); $post->body = $request->input('body'); + $post->draft = $draft; + $post->public = $public; $post->user_id = auth()->user()->id; $post->cover_image = $filenameToStore; $post->save(); diff --git a/public/css/style.css b/public/css/style.css index 6dbcbbbe716d1dcc25e367d9c0af6a74cd27cc33..499310ba4179948ec90eed4b7dc06a3f2903f2ba 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -57,6 +57,10 @@ border-radius: 50%; } +.post-title { + display: inline-block; +} + .navbar { background-color: #003365 !important; border-radius: 0px !important; diff --git a/resources/views/admin/createpost.blade.php b/resources/views/admin/createpost.blade.php index ec05580298d3068a210c5397cbe8dfed52316603..7c9f630b087f52920f8165812e19e397889eca7d 100644 --- a/resources/views/admin/createpost.blade.php +++ b/resources/views/admin/createpost.blade.php @@ -11,13 +11,43 @@ {{Form::label('title', 'Title')}} {{Form::text('title', '', ['class' => 'form-control', 'placeholder' => 'Title'])}} </div> + + <table class="table" style="border-width:0px;"> + <tbody> + <tr> + <div class="form-group"> + <td>{{Form::label('draft', 'Save As Draft')}}</td> + <td> + <label class="switch"> + <input name="draft" id="draft" value="yes" type="checkbox" checked> + <span class="slider round"></span> + </label> + </td> + </div> + </tr> + <tr> + <div class="form-group"> + <td>{{Form::label('public', 'Save As Public')}}</td> + <td> + <label class="switch"> + <input name="public" id="public" value="yes" type="checkbox" checked> + <span class="slider round"></span> + </label> + </td> + </div> + </tr> + </tbody> + </table> + <div class="form-group"> {{Form::label('body', 'Body')}} {{Form::textarea('body', '', ['id' => 'article-ckeditor', 'class' => 'form-control', 'placeholder' => 'Body'])}} </div> + <div class="form-group"> {{Form::file('cover_image')}} </div> + <div class="bottomButton"> {{Form::submit('Submit', ['class' => 'btn btn-primary'])}} <a onclick="return confirm('Are you sure you want to leave?')" class="pull-right onclick btn btn-danger" href="/posts"> diff --git a/resources/views/admin/showeachpost.blade.php b/resources/views/admin/showeachpost.blade.php index 62d42ce7bf6b3caf40521383c9954a65dfa13585..8a91490f6a819a28e27fdffeabf1ff3d771841fd 100644 --- a/resources/views/admin/showeachpost.blade.php +++ b/resources/views/admin/showeachpost.blade.php @@ -1,7 +1,18 @@ @extends('layouts.app') @section('content') - <h1>{{$post->title}}</h1> + + <span> + <h1 class="post-title">{{$post->title}}</h1> + <h5 class="post-title"> + @if ($post->draft == '1') + <span style="color:red;">Draft</span> + @else + <span style="color:green;">Published</span> + @endif + </h5> + </span> + <!--@if ($post->cover_image !== 'noimage.jpg') <div class="row"> <div class="col-8"> @@ -34,7 +45,17 @@ <div class="footer-article"> <hr> - <small>Written on {{$post->created_at}} by {{$post->user->name}}</small> + <h5> + @if ($post->public == '1') + Public + @else + Private + @endif + Post + </h5> + <small>Written on {{$post->created_at}}</small><br> + <small>Last Editted on {{$post->updated_at}}</small><br> + <small>by {{$post->user->name}}</small> <hr> @if(!Auth::guest() && Auth::user()->IsAdmin == 1)