Erster Upload
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\User\Resources\SpiceResource\Pages;
|
||||
|
||||
use App\Filament\User\Resources\SpiceResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateSpice extends CreateRecord
|
||||
{
|
||||
protected static string $resource = SpiceResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\User\Resources\SpiceResource\Pages;
|
||||
|
||||
use App\Filament\User\Resources\SpiceResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditSpice extends EditRecord
|
||||
{
|
||||
protected static string $resource = SpiceResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\User\Resources\SpiceResource\Pages;
|
||||
|
||||
use App\Filament\User\Resources\SpiceResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListSpices extends ListRecords
|
||||
{
|
||||
protected static string $resource = SpiceResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\User\Resources\SpiceResource\Widgets;
|
||||
|
||||
use Leandrocfe\FilamentApexCharts\Widgets\ApexChartWidget;
|
||||
use Filament\Support\RawJs;
|
||||
use App\Models\Spice;
|
||||
|
||||
class SpiceChart extends ApexChartWidget {
|
||||
protected static ?string $chartId = 'spiceChart';
|
||||
protected static ?string $heading = 'Rohstoffmengen im Lager';
|
||||
|
||||
protected function getOptions(): array {
|
||||
$data = Spice::all();
|
||||
|
||||
$data_array = [];
|
||||
$labels = [];
|
||||
foreach ($data as $label) {
|
||||
if ($label->unit == 'grams') {
|
||||
$data_array[] = round($label->quantity / 1000, 2);
|
||||
$labels[] = $label->name . ' (kg)';
|
||||
} else {
|
||||
$data_array[] = $label->quantity;
|
||||
if ($label->unit == 'pieces') {
|
||||
$labels[] = $label->name . ' (Stück)';
|
||||
} elseif ($label->unit == 'liter') {
|
||||
$labels[] = $label->name . ' (Liter)';
|
||||
} else {
|
||||
$labels[] = $label->name . ' (' . ucfirst($label->unit) . ')';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return [
|
||||
'chart' => [
|
||||
'type' => 'bar',
|
||||
'height' => 300,
|
||||
],
|
||||
'series' => [
|
||||
[
|
||||
'name' => 'BasicBarChart',
|
||||
'data' => $data_array,
|
||||
],
|
||||
],
|
||||
'xaxis' => [
|
||||
'categories' => $labels,
|
||||
'labels' => [
|
||||
'style' => [
|
||||
'fontFamily' => 'inherit',
|
||||
],
|
||||
],
|
||||
],
|
||||
'yaxis' => [
|
||||
'labels' => [
|
||||
'style' => [
|
||||
'fontFamily' => 'inherit',
|
||||
],
|
||||
],
|
||||
],
|
||||
'colors' => ['#f59e0b'],
|
||||
'plotOptions' => [
|
||||
'bar' => [
|
||||
'borderRadius' => 3,
|
||||
'horizontal' => false,
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
protected function extraJsOptions(): ?RawJs {
|
||||
return RawJs::make(<<<'JS'
|
||||
{
|
||||
xaxis: {
|
||||
labels: {
|
||||
formatter: function (val, timestamp, opts) {
|
||||
return val.replace('( ', '(')
|
||||
}
|
||||
}
|
||||
},
|
||||
dataLabels: {
|
||||
enabled: true,
|
||||
formatter: function (val, opt) {
|
||||
return val+''+opt.w.globals.labels[opt.dataPointIndex].match(/\((.*?)\)/)[1]
|
||||
},
|
||||
dropShadow: {
|
||||
enabled: true
|
||||
},
|
||||
}
|
||||
}
|
||||
JS);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user