From 3ab61ec3faadb00493cfe4b8be4b45fbb71fe395 Mon Sep 17 00:00:00 2001 From: liapples Date: Sat, 13 Nov 2021 00:04:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=87=AA=E8=90=A5=E4=BA=A7?= =?UTF-8?q?=E5=93=81title=E4=B8=BA=E7=A9=BA=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/AdminSupplier/Metrics/Examples/SalesExamples.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/AdminSupplier/Metrics/Examples/SalesExamples.php b/app/AdminSupplier/Metrics/Examples/SalesExamples.php index 17a4c69..2d033eb 100644 --- a/app/AdminSupplier/Metrics/Examples/SalesExamples.php +++ b/app/AdminSupplier/Metrics/Examples/SalesExamples.php @@ -54,7 +54,7 @@ class SalesExamples extends Bar public function fill() { $warehouse = OrderProductItem::query() - ->with('product') + ->with(['product', 'order:id,title']) ->select('*') ->addSelect(DB::raw('count(id) as count_id')) ->whereHas('order',function ($query) { @@ -68,9 +68,10 @@ class SalesExamples extends Bar //$warehouse = []; $data = $categories = []; foreach ($warehouse as $v) { - array_push($this->labels, $v->product->title); + $title = $v->product->title ?? $v->title; + array_push($this->labels, $title); array_push($data, $v->count_id); - $categories[] = [$v->product->title]; + $categories[] = [$title]; } $this->withChart($data, $categories);