Widget Time counter works locally but not on production

So this widget basically shows you how many hours are there on a project. This works fine on localhost, but it just shows 0:00 on production. Any ideas?
<?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'),

];
}
}
<?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'),

];
}
}
2 Replies
Dan Harrin
Dan Harrin2y ago
the only explanation is if there are no TimeRegistration with the correct project_id
Matthew
MatthewOP2y ago
Thanks, in that case, I will look into that
Want results from more Discord servers?
Add your server