Lots of changes

This commit is contained in:
Simon Pocrnjič
2024-11-13 22:11:07 +01:00
parent 90a5858320
commit 953ff38d64
76 changed files with 2822 additions and 427 deletions
+18 -5
View File
@@ -15,13 +15,26 @@ public function __construct(LarapexChart $chart)
public function build($options = null)
{
$data = \App\Models\ClientCase::query()
->selectRaw('EXTRACT(MONTH from created_at) as month, COUNT(id) as count')
->limit(6)
->whereRaw('EXTRACT(MONTH from created_at) > EXTRACT(MONTH from (NOW() - INTERVAL \'6 month\')) ')
->groupByRaw('EXTRACT(MONTH from created_at)')
->orderByRaw('EXTRACT(MONTH from created_at)')
->get();
$months = $data->pluck('month')->map(
fn($nu)
=> \DateTime::createFromFormat('!m', $nu)->format('F'))->toArray();
$newCases = $data->pluck('count')->toArray();
return $this->chart->areaChart()
->setTitle('Contracts during last six months.')
->setSubtitle('New and Completed.')
->addData('New', [4, 9, 5, 2, 1, 8])
->addData('Completed', [7, 2, 7, 2, 5, 4])
->setTitle('Cases during last six months.')
->addData('New cases', $newCases)
//->addData('Completed', [7, 2, 7, 2, 5, 4])
->setColors(['#1A56DB', '#ff6384'])
->setXAxis(['January', 'February', 'March', 'April', 'May', 'June'])
->setXAxis($months)
->setToolbar(true)
->toVue();
}