|
...
|
...
|
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Api; |
|
|
|
use App\Enums\Common\Code;
|
|
|
|
use App\Models\Product\Product;
|
|
|
|
use App\Services\ProjectServer;
|
|
|
|
use App\Utils\LogUtils;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use Illuminate\Support\Arr;
|
|
|
|
|
|
...
|
...
|
@@ -31,13 +32,15 @@ class ProductController extends BaseController |
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
$gallery = Product::where('status', Product::STATUS_ON)->whereNotNull('gallery')->inRandomOrder()->value('gallery');
|
|
|
|
$gallery = array_map(function ($item) use ($project) {
|
|
|
|
return getImageUrl($item, $project['storage_type'], $project['project_location']);
|
|
|
|
}, Arr::pluck($gallery, 'url'));
|
|
|
|
$info = Product::where('status', Product::STATUS_ON)->whereNotNull('gallery')->inRandomOrder()->select(['title', 'seo_mate', 'gallery'])->first();
|
|
|
|
$info['gallery'] = array_map(function ($item) use ($project) {
|
|
|
|
$item['url'] = getImageUrl($item['url'], $project['storage_type'], $project['project_location']);
|
|
|
|
return $item;
|
|
|
|
}, $info['gallery']);
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
$gallery = [];
|
|
|
|
LogUtils::error('Project Id: ' . $project_id . ' getProductImages error:' . $e->getMessage());
|
|
|
|
$info = [];
|
|
|
|
}
|
|
|
|
$this->response('success', Code::SUCCESS, $gallery);
|
|
|
|
$this->response('success', Code::SUCCESS, $info);
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|