Stuff
This commit is contained in:
parent
926259a3de
commit
a40a9a523e
5 changed files with 71 additions and 6 deletions
|
@ -59,7 +59,9 @@ class PublicController extends BaseController
|
||||||
"pages" => ($g->count() / 10),
|
"pages" => ($g->count() / 10),
|
||||||
"preview" => $preview,
|
"preview" => $preview,
|
||||||
"next" => $next],
|
"next" => $next],
|
||||||
"data" => \App\Http\Resources\Gallery::collection($r)]);
|
"data" => [
|
||||||
|
"galleries" => \App\Http\Resources\Gallery::collection($r)
|
||||||
|
]]);
|
||||||
}
|
}
|
||||||
public function listGalleriesView($name, Request $request) {
|
public function listGalleriesView($name, Request $request) {
|
||||||
$tenant = Tenant::query()->where("url", "=", $name)->firstOrFail();
|
$tenant = Tenant::query()->where("url", "=", $name)->firstOrFail();
|
||||||
|
@ -82,6 +84,28 @@ class PublicController extends BaseController
|
||||||
return view("themes.tenant.".$theme.".list", ["galleries" => $galleries, "tenant" => $tenant]);
|
return view("themes.tenant.".$theme.".list", ["galleries" => $galleries, "tenant" => $tenant]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function listGalleryImagesViewAPI($tenant, $gallery, Request $request) {
|
||||||
|
$tenant = Tenant::query()->where("url", "=", $tenant)->firstOrFail();
|
||||||
|
$gallery = Gallery::getByTenantAndUrl($tenant->id, $gallery);
|
||||||
|
if($gallery->status == "online" || (Auth::check() && $gallery->status == "preview" && Auth::user()->id == $tenant->owner)) {
|
||||||
|
$images = Image::query()
|
||||||
|
->where("gallery", "=", $gallery->id)
|
||||||
|
->whereNull("deleted_at")
|
||||||
|
->orderBy("rating")
|
||||||
|
->orderBy("DateTimeOriginal")
|
||||||
|
->get();
|
||||||
|
} else {
|
||||||
|
abort( 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$parser = new \Parsedown();
|
||||||
|
$gallery->html = $parser->parse($gallery->description);
|
||||||
|
|
||||||
|
return response()->json(["data" => ["gallery" => new \App\Http\Resources\Gallery($gallery), "images" => \App\Http\Resources\Image::collection(collect(($images)))]]);
|
||||||
|
|
||||||
|
return view("themes.gallery.".$theme.".list", ["gallery" => $gallery, "tenant" => $tenant, "images" => $images]);
|
||||||
|
}
|
||||||
|
|
||||||
public function listGalleryImagesView($tenant, $gallery, Request $request) {
|
public function listGalleryImagesView($tenant, $gallery, Request $request) {
|
||||||
$tenant = Tenant::query()->where("url", "=", $tenant)->firstOrFail();
|
$tenant = Tenant::query()->where("url", "=", $tenant)->firstOrFail();
|
||||||
$gallery = Gallery::getByTenantAndUrl($tenant->id, $gallery);
|
$gallery = Gallery::getByTenantAndUrl($tenant->id, $gallery);
|
||||||
|
|
|
@ -15,12 +15,14 @@ class Gallery extends JsonResource
|
||||||
public function toArray($request)
|
public function toArray($request)
|
||||||
{
|
{
|
||||||
$data = [];
|
$data = [];
|
||||||
$data["id"] = $this->id;
|
#$data["id"] = $this->id;
|
||||||
$data["name"] = $this->name;
|
$data["name"] = $this->name;
|
||||||
$data["created"] = $this->gallery_create_time;
|
$data["created"] = $this->gallery_create_time;
|
||||||
$data["url"] = [
|
$data["url"] = [
|
||||||
"name" => $this->url,
|
"name" => $this->url,
|
||||||
"url" => url("/".$this->getTenant()->url."/".$this->url)];
|
"url" => url("/".$this->getTenant()->url."/".$this->url),
|
||||||
|
"json" => url("/".$this->getTenant()->url."/".$this->url.".json"),
|
||||||
|
];
|
||||||
$data["mainImage"] = [
|
$data["mainImage"] = [
|
||||||
"id" => $this->main_image,
|
"id" => $this->main_image,
|
||||||
"url" => [
|
"url" => [
|
||||||
|
@ -29,8 +31,11 @@ class Gallery extends JsonResource
|
||||||
"big" => url("/".$this->getTenant()->url."/".$this->url."/".$this->main_image."/file?size=big")
|
"big" => url("/".$this->getTenant()->url."/".$this->url."/".$this->main_image."/file?size=big")
|
||||||
]];
|
]];
|
||||||
$data["description"] = $this->description;
|
$data["description"] = $this->description;
|
||||||
$data["tags"] = json_decode($this->tags);
|
$t = json_decode($this->tags);
|
||||||
|
foreach ($t as $i => $g) {
|
||||||
|
$t[$i] = trim($g);
|
||||||
|
}
|
||||||
|
$data["tags"] = $t;
|
||||||
return $data;
|
return $data;
|
||||||
#return parent::toArray($request);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
31
app/Http/Resources/Image.php
Normal file
31
app/Http/Resources/Image.php
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
class Image extends JsonResource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Transform the resource into an array.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function toArray($request)
|
||||||
|
{
|
||||||
|
$d = [];
|
||||||
|
#$d["id"] = $this->id;
|
||||||
|
$d["name"] = $this->name;
|
||||||
|
$d["description"] = $this->description;
|
||||||
|
$d["filename"] = $this->filename;
|
||||||
|
$d["size"] = $this->size;
|
||||||
|
$d["exit"] = ["DateTimeOriginal" => $this->DateTimeOriginal];
|
||||||
|
$d["url"] = [
|
||||||
|
"small" => url("/".$this->getGallery()->getTenant()->url."/".$this->getGallery()->url."/".$this->id."/file?size=small"),
|
||||||
|
"medium" => url("/".$this->getGallery()->getTenant()->url."/".$this->getGallery()->url."/".$this->id."/file?size=medium"),
|
||||||
|
"big" => url("/".$this->getGallery()->getTenant()->url."/".$this->getGallery()->url."/".$this->id."/file?size=big")
|
||||||
|
];
|
||||||
|
return $d;
|
||||||
|
}
|
||||||
|
}
|
|
@ -42,4 +42,9 @@ class Image extends Authenticatable
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function getGallery()
|
||||||
|
{
|
||||||
|
$gallery = Gallery::query()->where("id", "=", $this->gallery)->firstOrFail();
|
||||||
|
return $gallery;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,8 +62,8 @@ Route::middleware([\App\Http\Middleware\TenanMiddleware::class, \App\Http\Middle
|
||||||
|
|
||||||
Route::get("/{name}.json", [\App\Http\Controllers\PublicController::class, 'listGalleriesViewAPI'])->middleware([\App\Http\Middleware\TenanMiddleware::class]);
|
Route::get("/{name}.json", [\App\Http\Controllers\PublicController::class, 'listGalleriesViewAPI'])->middleware([\App\Http\Middleware\TenanMiddleware::class]);
|
||||||
Route::get("/{name}", [\App\Http\Controllers\PublicController::class, 'listGalleriesView'])->middleware([\App\Http\Middleware\TenanMiddleware::class]);
|
Route::get("/{name}", [\App\Http\Controllers\PublicController::class, 'listGalleriesView'])->middleware([\App\Http\Middleware\TenanMiddleware::class]);
|
||||||
|
Route::get("/{tenant}/{gallery}.json", [\App\Http\Controllers\PublicController::class, 'listGalleryImagesViewAPI'])->middleware([\App\Http\Middleware\TenanMiddleware::class]);
|
||||||
Route::get("/{tenant}/{gallery}", [\App\Http\Controllers\PublicController::class, 'listGalleryImagesView'])->middleware([\App\Http\Middleware\TenanMiddleware::class]);
|
Route::get("/{tenant}/{gallery}", [\App\Http\Controllers\PublicController::class, 'listGalleryImagesView'])->middleware([\App\Http\Middleware\TenanMiddleware::class]);
|
||||||
Route::get("/{tenant}/{gallery}.json", [\App\Http\Controllers\PublicController::class, 'listGalleryImagesView'])->middleware([\App\Http\Middleware\TenanMiddleware::class]);
|
|
||||||
Route::get("/{tenant}/{gallery}/{image}/file", [\App\Http\Controllers\PublicController::class, 'returnImageFile']);
|
Route::get("/{tenant}/{gallery}/{image}/file", [\App\Http\Controllers\PublicController::class, 'returnImageFile']);
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue