diff options
-rw-r--r-- | app/Http/Controllers/GalleryController.php | 6 | ||||
-rw-r--r-- | app/Http/Controllers/NewsController.php | 11 | ||||
-rw-r--r-- | resources/views/pages/news-admin.blade.php | 22 | ||||
-rw-r--r-- | resources/views/pages/news.blade.php | 31 |
4 files changed, 32 insertions, 38 deletions
diff --git a/app/Http/Controllers/GalleryController.php b/app/Http/Controllers/GalleryController.php index 064be02..d2a04c5 100644 --- a/app/Http/Controllers/GalleryController.php +++ b/app/Http/Controllers/GalleryController.php @@ -8,6 +8,7 @@ use dd; use Illuminate\Support\Facades\Redirect; use Illuminate\Support\Facades\Validator; +use Illuminate\Support\Facades\Storage; use App\Models\Image; @@ -102,7 +103,10 @@ class GalleryController extends Controller */ public function destroy($id) { - Image::findOrFail($id)->delete(); + $img = Image::findOrFail($id); + $path = $img->path . $img->name; + Storage::delete($path); + $img->delete(); return Redirect::back()->with('status', 'Image deleted.'); } } diff --git a/app/Http/Controllers/NewsController.php b/app/Http/Controllers/NewsController.php index de7a823..8be535e 100644 --- a/app/Http/Controllers/NewsController.php +++ b/app/Http/Controllers/NewsController.php @@ -34,9 +34,8 @@ class NewsController extends Controller */ public function create() { - // - $data = Post::orderBy('created_at', 'desc')->get(); - return view('pages.news-admin', compact('data')); + //$data = Post::orderBy('created_at', 'desc')->get(); + return view('pages.news-admin');//, compact('data')); } /** @@ -127,8 +126,8 @@ class NewsController extends Controller $post->text = $request->text; $post->saveOrFail(); - return Redirect::route('newsAdd')->with('statusE', "Post edited."); - } else return Redirect::route('newsAdd'); + return Redirect::route('news')->with('status', "Post edited."); + } else return Redirect::route('news'); } /** @@ -142,6 +141,6 @@ class NewsController extends Controller $post = Post::findOrFail($id); $title = $post->title; $post->delete(); - return Redirect::back()->with('statusE', "Post \"$title\" deleted."); + return Redirect::back()->with('status', "Post \"$title\" deleted."); } } diff --git a/resources/views/pages/news-admin.blade.php b/resources/views/pages/news-admin.blade.php index 55c94e6..67e64ad 100644 --- a/resources/views/pages/news-admin.blade.php +++ b/resources/views/pages/news-admin.blade.php @@ -5,28 +5,6 @@ @section('navbar', View::make('inc.navbar')) @section('content') - <h3>News Administration:</h3> - @if (session('statusE')) - <div class="alert alert-success"> - {{ session('statusE') }} - </div> - @endif - @if (count($data) > 0) - <div class="p-0 mt-3 col-lg-6 table-responsive"> - <table class="table table-bordered"> - @foreach ($data as $row) - <tr> - <td class="align-middle">{{ $row->title }}</td> - <td><a href="{{ route('newsEdit', $row->id) }}" class="btn btn-warning">Edit</a></td> - <td><a href="{{ route('newsDelete', $row->id) }}" class="btn btn-danger">Delete</a></td> - </tr> - @endforeach - </table> - </div> - @else - <strong>There are currently no callsigns.</strong> - @endif - <h3 class="mt-4">Add Post:</h3> @if (session('status')) <div class="alert alert-success"> diff --git a/resources/views/pages/news.blade.php b/resources/views/pages/news.blade.php index d700ce7..33ff039 100644 --- a/resources/views/pages/news.blade.php +++ b/resources/views/pages/news.blade.php @@ -3,14 +3,27 @@ @section('title', 'News') @section('content') - @foreach($news as $post) - <div class="card mb-3"> - <div class="card-body"> - <h2 class="card-title">{{ $post->title }}</h2> - <h6 class="card-subtitle mb-2 text-muted">Published at {{ $post->created_at->format('Y-m-d') }}@isset ($post->author) by {{$post->author }}@endisset</h4> - <div class="card-text">{!! $post->text !!}</div> + @if (session('statusE')) + <div class="alert alert-success"> + {{ session('status') }} + </div> + @endif + @if (count($news) > 0) + @foreach($news as $post) + <div class="card mb-3"> + <div class="card-body"> + <h2 class="card-title">{{ $post->title }}</h2> + <h6 class="card-subtitle mb-2 text-muted">Published at {{ $post->created_at->format('Y-m-d') }}@isset ($post->author) by {{$post->author }}@endisset</h4> + <div class="card-text">{!! $post->text !!}</div> + </div> + <div class="mt-3 card-footer"> + <a href="{{ route('newsEdit', $post->id) }}" class="btn btn-warning">Edit</a> + <a href="{{ route('newsDelete', $post->id) }}" class="float-right btn btn-danger">Delete</a> + </div> </div> - </div> - @endforeach - {{ $news->links() }} + @endforeach + {{ $news->links() }} + @else + <strong class="text-center">There are no news.</strong> + @endif @endsection() |