diff --git a/app/Http/Controllers/GalleryController.php b/app/Http/Controllers/GalleryController.php index 2630bac..0d5a90b 100644 --- a/app/Http/Controllers/GalleryController.php +++ b/app/Http/Controllers/GalleryController.php @@ -99,6 +99,34 @@ class GalleryController extends BaseController return \redirect("/g/".$gallery->url."/upload"); } + public function editGalleryView($name, Request $request) { + $gallery = Gallery::getByTenantAndUrl(session("current_tenant_id"), $name); + session(['_old_input.name' => $gallery->name]); + session(['_old_input.description' => $gallery->description]); + session(['_old_input.date' => $gallery->gallery_create_time]); + session(['_old_input.url' => $gallery->url]); + return view("gallery.new"); + } + + public function editGallery($name, Request $request) { + $validated = $request->validate([ + 'name' => 'required|max:255', + 'description' => 'max:15000000', + 'url' => 'required|regex:/^[a-z0-9\-]{8,30}$/i', + 'date' => 'required|regex:/^\d{4}-\d{2}-\d{2}$/i', + ]); + + $gallery = Gallery::getByTenantAndUrl(session("current_tenant_id"), $name); + $gallery->name = $validated["name"]; + $gallery->description = $validated["description"]; + $gallery->url = $validated["url"]; + $gallery->gallery_create_time = $validated["date"]; + $gallery->saveOrFail(); + + + return Redirect::back()->with(["msg" => "Saved"]); + } + public function imagesUploadView($name) { return view("gallery.upload"); } @@ -124,7 +152,6 @@ class GalleryController extends BaseController $gallery->saveOrFail(); } - return $name; } diff --git a/app/Http/Controllers/PublicController.php b/app/Http/Controllers/PublicController.php index d1591e4..ddb5d0a 100644 --- a/app/Http/Controllers/PublicController.php +++ b/app/Http/Controllers/PublicController.php @@ -27,7 +27,7 @@ class PublicController extends BaseController public function listGalleriesView($name) { $tenant = Tenant::query()->where("url", "=", $name)->firstOrFail(); - $galleries = Gallery::query()->where("tenant", "=", $tenant->id)->get(); + $galleries = Gallery::query()->where("tenant", "=", $tenant->id)->orderByDesc("gallery_create_time")->orderByDesc("created_at")->get(); return view("themes.tenant.kuvia-blog.list", ["galleries" => $galleries, "tenant" => $tenant]); } diff --git a/resources/views/gallery/index.blade.php b/resources/views/gallery/index.blade.php index 405db43..145a842 100644 --- a/resources/views/gallery/index.blade.php +++ b/resources/views/gallery/index.blade.php @@ -1,8 +1,11 @@ @extends('layout/template') @section('content') - New Gallery -

Gallery

+
+
+ New Gallery +

Gallery

+
@@ -34,6 +37,7 @@ @@ -42,6 +46,7 @@ @endforeach
+
diff --git a/resources/views/gallery/new.blade.php b/resources/views/gallery/new.blade.php index 65cafb0..c26757b 100644 --- a/resources/views/gallery/new.blade.php +++ b/resources/views/gallery/new.blade.php @@ -1,23 +1,26 @@ @extends('layout/template') @section('content') -

Gallery

-
- @if ($errors->any()) -
- -
- @endif +
+

Gallery

+ @if ($errors->any()) +
+
    + @foreach ($errors->all() as $error) +
  • {{ $error }}
  • + @endforeach +
+
+ @endif +
+
+
+
@csrf - - +
@@ -38,7 +41,14 @@
- +
+
+
+ + +
+
+ @endsection diff --git a/resources/views/layout/template.blade.php b/resources/views/layout/template.blade.php index 0e69c10..e61a3ea 100644 --- a/resources/views/layout/template.blade.php +++ b/resources/views/layout/template.blade.php @@ -15,7 +15,7 @@