<?php
namespace App\Filament\Resources\ProjectResource\Widgets;
use App\Filament\Resources\ProjectResource\Pages\ViewProject;
use App\Models\Project;
use App\Models\TimeRegistration;
use Filament\Forms\Components\TimePicker;
use Filament\Widgets\StatsOverviewWidget as BaseWidget;
use Filament\Widgets\StatsOverviewWidget\Card;
use Illuminate\Database\Eloquent\Model;
class StatsView extends BaseWidget
{
public ?Model $record = null;
protected function getCards(): array
{
$test = intval(TimeRegistration::where('project_id', $this->record->id)->sum('time'))/10000; // replace 'hours' with the column name of hours in TimeRegistrations
$timeNumber = round($test, 2);
$timeString = number_format($timeNumber, 2, ':', '');
return [
Card::make('Hours on this project', $timeString)
->description('32k increase')
->descriptionIcon('heroicon-s-trending-up')
->color('success'),
];
}
}