|
|
|
@ -3,6 +3,7 @@ |
|
|
|
namespace App\Http\Controllers\Api; |
|
|
|
|
|
|
|
use App\Http\Controllers\Controller; |
|
|
|
use App\Models\AgentProduct; |
|
|
|
use App\Models\Article; |
|
|
|
use Illuminate\Support\Facades\Storage; |
|
|
|
|
|
|
|
@ -53,6 +54,19 @@ class ArticleController extends Controller |
|
|
|
return $this->error('文章不存在或已被删除'); |
|
|
|
} |
|
|
|
$article->image = Storage::disk('public')->url('') . $article->image; |
|
|
|
|
|
|
|
if ($article->agent_product_ids) { |
|
|
|
$product = AgentProduct::list($this->agent_id) |
|
|
|
->whereIn('id', $article->agent_product_ids) |
|
|
|
->get(); |
|
|
|
if (!$product->isEmpty()) { |
|
|
|
$prefix = Storage::disk('public')->url(''); |
|
|
|
foreach ($product as &$v) { |
|
|
|
$v->pictures = array_map(fn($item) => $prefix . $item, $v->pictures); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
$article->product = $product; |
|
|
|
return $this->success($article); |
|
|
|
} |
|
|
|
} |