This commit is contained in:
Kekskurse 2021-01-17 15:32:25 +01:00
parent 2efee483dd
commit 0fff346f15
7 changed files with 64 additions and 20 deletions

View file

@ -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;
}

View file

@ -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]);
}

View file

@ -1,8 +1,11 @@
@extends('layout/template')
@section('content')
<a href="/g/new" class="btn btn-outline-success" style="float: right;">New Gallery</a>
<h1>Gallery</h1>
<div class="row" style="margin-top: 20px;">
<div class="col-md-12" style="margin-bottom: 10px;">
<a href="/g/new" class="btn btn-outline-success" style="float: right;">New Gallery</a>
<h1>Gallery</h1>
</div>
<div style="clear: both; margin-bottom: 10px;"></div>
<div class="col-md-12">
<table class="table table-striped">
@ -34,6 +37,7 @@
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="/g/{{$gallery->url}}/upload">Upload Images</a>
<a class="dropdown-item" href="/g/{{$gallery->url}}">Bilder</a>
<a class="dropdown-item" href="/g/{{$gallery->url}}/edit">Bearbeiten</a>
<a class="dropdown-item" href="#">Delete</a>
</div>
</div>
@ -42,6 +46,7 @@
@endforeach
</table>
</div>
</div>

View file

@ -1,23 +1,26 @@
@extends('layout/template')
@section('content')
<h1>Gallery</h1>
<div style="clear: both; margin-bottom: 10px;"></div>
@if ($errors->any())
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<div class="row" style="margin-top: 20px;">
<div class="col-md-12">
<h1>Gallery</h1>
@if ($errors->any())
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
</div>
</div>
<div class="row">
<div class="col-md-9">
<form method="post">
@csrf
<input name="name" value="{{ old('name') }}" placeholder="Name" class="form-control">
<textarea name="description" value="{{ old('description') }}" placeholder="Description" class="form-control"></textarea>
<textarea name="description" style="height: 300px;" placeholder="Description" class="form-control">{{ old('description') }}</textarea>
<div class="accordion" id="accordionExample">
@ -38,7 +41,14 @@
</div>
</div>
<input type="submit" class="btn btn-outline-success" value="Create" style="margin-top: 10px;">
<input type="submit" class="btn btn-outline-success" value="Save" style="margin-top: 10px;">
</form>
</div>
<div class="col-md-3">
<div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" id="customSwitch1" checked="">
<label class="custom-control-label" for="customSwitch1">Publish</label>
</div>
</div>
</div>
@endsection

View file

@ -15,7 +15,7 @@
<div class="collapse navbar-collapse" id="navbarColor02">
@auth
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<li class="nav-item">
<a class="nav-link" href="/d">Dashboard</a>
</li>
<li class="nav-item">

View file

@ -1,7 +1,7 @@
@extends('layout/template')
@section('content')
<div class="row">
<div class="row" style="margin-top: 20px;">
<div class="col-md-12">
@foreach($galleries as $gallery)

View file

@ -40,6 +40,8 @@ Route::middleware([\App\Http\Middleware\TenanMiddleware::class])->group(function
Route::get("/g/{url}/upload", [\App\Http\Controllers\GalleryController::class, 'imagesUploadView']);
Route::post("/g/{url}/upload", [\App\Http\Controllers\GalleryController::class, 'imageUpload']);
Route::get("/g/{url}", [\App\Http\Controllers\GalleryController::class, 'showImagesView']);
Route::get("/g/{url}/edit", [\App\Http\Controllers\GalleryController::class, 'editGalleryView']);
Route::post("/g/{url}/edit", [\App\Http\Controllers\GalleryController::class, 'editGallery']);
Route::get("/g/{url}/setDefault", [\App\Http\Controllers\GalleryController::class, 'setDefault']);
});