initial: bootstrap from BukidBountyApp base
This commit is contained in:
60
app/Http/Controllers/Photos/PhotoGallery.php
Normal file
60
app/Http/Controllers/Photos/PhotoGallery.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Photos;
|
||||
|
||||
use App\Models\Market\Product;
|
||||
use App\Models\Market\Store;
|
||||
use App\Models\User;
|
||||
use Hypervel\Http\Request;
|
||||
|
||||
class PhotoGallery
|
||||
{
|
||||
public function handle(Request $request, string $type)
|
||||
{
|
||||
$hash = $request->input('target', false);
|
||||
|
||||
// Validate inputs
|
||||
if (!$type) {
|
||||
return response()->json(false);
|
||||
}
|
||||
|
||||
if (!$hash || is_numeric($hash)) {
|
||||
return response()->json(false);
|
||||
}
|
||||
|
||||
$photoUrls = null;
|
||||
|
||||
switch ($type) {
|
||||
// case 'ProductMarket':
|
||||
// // Assuming you have a helper function RequestPhotos($hash, $type)
|
||||
// $result = RequestPhotos($hash, $type);
|
||||
// return response()->json($result);
|
||||
|
||||
case 'User':
|
||||
$photoUrls = User::where('hashkey', $hash)
|
||||
->value('photourl') ?? false;
|
||||
break;
|
||||
|
||||
case 'StoreMarket':
|
||||
$photoUrls = Store::where('hashkey', $hash)->value('photourl') ?? false;
|
||||
break;
|
||||
|
||||
case 'ProductMarket':
|
||||
$photoUrls = Product::where('hashkey', $hash)->value('photourl') ?? false;
|
||||
break;
|
||||
|
||||
default:
|
||||
return response()->json(false);
|
||||
}
|
||||
|
||||
if (!$photoUrls) {
|
||||
return response()->json(false);
|
||||
}
|
||||
|
||||
// $decoded = tryjsondecode($photoUrls);
|
||||
|
||||
return response()->json($photoUrls);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user