在模型product.php中增加以下方法.數據庫圖片字段為image.存儲的圖片相對路徑 public function getImageUrlAttribute() { // 如果 image 字段本身就已經是完整的 url 就直接返回 if (Str::startsWith($this->attributes['image'], ['http://', 'https://'])) { return $this->attributes['image']; } return \Storage::disk('public')->url($this->attributes['image']); } Laravel 的模型訪問器會自動把下划線改為駝峰,所以 image_url 對應的就是 getImageUrlAttribute 因此在模板中圖片路徑就得寫$product->image_url