fixing bugs

This commit is contained in:
2026-02-16 15:09:41 +01:00
parent c39b8085af
commit fb1c28a0ba
14 changed files with 238 additions and 19 deletions

View File

@@ -14,6 +14,7 @@
final class AnswerResource extends Resource
{
/**
* The model the resource corresponds to.
*

View File

@@ -1,11 +1,16 @@
<?php
declare(strict_types=1);
namespace App\Nova\Dashboards;
use Laravel\Nova\Cards\Help;
use App\Nova\Metrics\ScreeningsTrend;
use App\Nova\Metrics\SessionsTrend;
use App\Nova\Metrics\TotalScreenings;
use App\Nova\Metrics\TotalSessions;
use Laravel\Nova\Dashboards\Main as Dashboard;
class Main extends Dashboard
final class Main extends Dashboard
{
/**
* Get the cards for the dashboard.
@@ -15,7 +20,10 @@ class Main extends Dashboard
public function cards(): array
{
return [
new Help,
new TotalSessions,
new TotalScreenings,
new SessionsTrend,
new ScreeningsTrend,
];
}
}

View File

@@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace App\Nova\Metrics;
use App\Models\Screening;
use Laravel\Nova\Http\Requests\NovaRequest;
use Laravel\Nova\Metrics\Trend;
final class ScreeningsTrend extends Trend
{
public ?int $cacheFor = null;
public function calculate(NovaRequest $request): mixed
{
return $this->countByDays($request, Screening::class);
}
public function name(): string
{
return 'Screenings';
}
public function ranges(): array
{
return [
30 => '30 Days',
60 => '60 Days',
90 => '90 Days',
];
}
}

View File

@@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace App\Nova\Metrics;
use App\Models\Session;
use Laravel\Nova\Http\Requests\NovaRequest;
use Laravel\Nova\Metrics\Trend;
final class SessionsTrend extends Trend
{
public function calculate(NovaRequest $request): mixed
{
return $this->countByDays($request, Session::class);
}
public function name(): string
{
return 'Sessions';
}
public function ranges(): array
{
return [
30 => '30 Days',
60 => '60 Days',
90 => '90 Days',
];
}
public $cacheFor = null;
}

View File

@@ -0,0 +1,47 @@
<?php
declare(strict_types=1);
namespace App\Nova\Metrics;
use App\Models\Screening;
use Laravel\Nova\Http\Requests\NovaRequest;
use Laravel\Nova\Metrics\Value;
final class TotalScreenings extends Value
{
/**
* Calculate the value of the metric.
*/
public function calculate(NovaRequest $request): mixed
{
return $this->count($request, Screening::class);
}
/**
* Get the displayable name of the metric.
*/
public function name(): string
{
return 'Total Screenings';
}
/**
* Get the ranges available for the metric.
*/
public function ranges(): array
{
return [
30 => '30 Days',
60 => '60 Days',
365 => '365 Days',
'TODAY' => 'Today',
'ALL' => 'All Time',
];
}
/**
* Determine the amount of time the results should be cached.
*/
public $cacheFor = null;
}

View File

@@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace App\Nova\Metrics;
use App\Models\Session;
use Laravel\Nova\Http\Requests\NovaRequest;
use Laravel\Nova\Metrics\Value;
final class TotalSessions extends Value
{
public function calculate(NovaRequest $request): mixed
{
return $this->count($request, Session::class);
}
public function name(): string
{
return 'Total Sessions';
}
public function ranges(): array
{
return [
30 => '30 Days',
60 => '60 Days',
365 => '365 Days',
'TODAY' => 'Today',
'ALL' => 'All Time',
];
}
public $cacheFor = null;
}

View File

@@ -42,7 +42,7 @@ final class QuestionGroupResource extends Resource
*
* @var bool
*/
public static $displayInNavigation = false;
public static $displayInNavigation = true;
/**
* Get the displayable label of the resource.

View File

@@ -9,6 +9,17 @@
abstract class Resource extends NovaResource
{
public static function perPageOptions()
{
return [50, 100, 150];
}
public static function perPageViaRelationshipOptions()
{
return [10, 25, 50];
}
/**
* Build an "index" query for the given resource.
*/

View File

@@ -108,8 +108,7 @@ public function fields(NovaRequest $request): array
])
->displayUsingLabels()
->sortable()
->filterable()
->readonly(),
->filterable(),
Number::make('Score')
->sortable()
@@ -125,8 +124,7 @@ public function fields(NovaRequest $request): array
])
->displayUsingLabels()
->sortable()
->filterable()
->readonly(),
->filterable(),
Textarea::make('Additional Comments')
->rules('nullable'),

View File

@@ -74,19 +74,16 @@ public function fields(NovaRequest $request): array
Text::make('Job Title', 'job_title')
->sortable()
->filterable()
->copyable()
->readonly(),
->copyable(),
Text::make('Department')
->sortable()
->filterable()
->copyable()
->readonly(),
->copyable(),
Text::make('Phone')
->sortable()
->copyable()
->readonly(),
->copyable(),
Password::make('Password')
->onlyOnForms()