-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5e5dca6
commit e4d3b40
Showing
7 changed files
with
138 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
app/Filament/Resources/AnimalResource/Widgets/CowBreedPieChart.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources\AnimalResource\Widgets; | ||
|
||
use App\Models\Animal; | ||
use App\Models\AnimalProduction; | ||
use Illuminate\Contracts\View\View; | ||
use Leandrocfe\FilamentApexCharts\Widgets\ApexChartWidget; | ||
|
||
class CowBreedPieChart extends ApexChartWidget | ||
{ | ||
|
||
protected int | string | array $columnSpan = 2; | ||
protected static string $chartId = 'cowBreedPieChart'; | ||
protected static ?string $heading = 'Types of Cow by Breed'; | ||
protected static ?int $contentHeight = 300; | ||
protected static ?string $pollingInterval = null; | ||
protected static bool $deferLoading = true; | ||
|
||
protected function getLoadingIndicator(): null|string|View | ||
{ | ||
return view('loading'); | ||
} | ||
|
||
|
||
protected function getOptions(): array | ||
{ | ||
|
||
if(!$this->readyToLoad) { | ||
return []; | ||
} | ||
|
||
$data = Animal::query() | ||
->groupBy('breed') | ||
->selectRaw('breed, COUNT(*) as quantity') | ||
->get() | ||
->toArray(); | ||
|
||
|
||
return [ | ||
'chart' => [ | ||
'type' => 'pie', | ||
'height' => 300, | ||
], | ||
'series' => array_column($data, 'quantity'), | ||
'labels' => array_column($data, 'breed'), | ||
'legend' => [ | ||
'labels' => [ | ||
'colors' => '#9ca3af', | ||
'fontWeight' => 600, | ||
], | ||
], | ||
// 'fill' => [ | ||
// 'type' => 'gradient', | ||
// 'gradient' => [ | ||
// 'shade' => 'dark', | ||
// 'gradientToColors' => ['dodgerblue', 'blue'], | ||
// 'shadeIntensity' => 1, | ||
// 'type' => 'vertical', | ||
// 'opacityFrom' => 1, | ||
// 'opacityTo' => 1, | ||
// 'stops' => [0, 90, 100] | ||
// ], | ||
// ], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,24 @@ | ||
#!/bin/sh | ||
|
||
cp /home/site/wwwroot/nginx/default /etc/nginx/sites-enabled/ && service nginx restart | ||
cd /home/site/wwwroot && cp .env.azure .env && php artisan key:generate && php artisan storage:link && php artisan config:cache && php artisan event:cache && php artisan route:cache && php artisan view:cache | ||
|
||
# File upload fix | ||
sed -i 's|abort_unless|//&|g' /home/site/wwwroot/vendor/livewire/livewire/src/Controllers/FileUploadHandler.php | ||
|
||
sed -i '/tmpfile/a $tmpfname = tempnam(sys_get_temp_dir(), "");\n$tmpFile = fopen($tmpfname, "w");' /home/site/wwwroot/vendor/livewire/livewire/src/TemporaryUploadedFile.php | ||
sed -i 's/$tmpFile/\/\/&/' /home/site/wwwroot/vendor/livewire/livewire/src/TemporaryUploadedFile.php | ||
|
||
mkdir /home/site/wwwroot/storage/app/public/livewire-tmp | ||
|
||
chmod -R 755 /home/site/wwwroot/storage | ||
|
||
# Nginx config | ||
cp /home/site/wwwroot/nginx/default /etc/nginx/sites-enabled/ && service nginx restart | ||
|
||
# Laravel config | ||
cd /home/site/wwwroot || echo "Unable to change directory" && exit 1 | ||
cp .env.azure .env | ||
#php artisan key:generate | ||
php artisan storage:link | ||
php artisan config:cache | ||
php artisan event:cache | ||
php artisan route:cache | ||
php artisan view:cache | ||
|
||
|
||
|