Skip to content
Snippets Groups Projects
Commit 7b940f1b authored by Rachel Sidney's avatar Rachel Sidney
Browse files

add backend for access and draft

parent d0f5ed90
No related merge requests found
......@@ -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();
......
......@@ -57,6 +57,10 @@
border-radius: 50%;
}
.post-title {
display: inline-block;
}
.navbar {
background-color: #003365 !important;
border-radius: 0px !important;
......
......@@ -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">
......
@extends('layouts.app')
@section('content')
<h1>{{$post->title}}</h1>
<span>
<h1 class="post-title">{{$post->title}}</h1>
<h5 class="post-title">&nbsp;
@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)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment