|
|
|
@ -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); |
|
|
|
|