I'm having following error :ENUM

After defining the 'status' attribute in the 'AppointmentResource' and using 'App\Enums\AppointmentStatus,' I have added 'protected $casts = ['status' => AppointmentStatus::class]' in the model. However, I am encountering an error that says, 'Class "App\Enums\AppointmentStatus" not found.' I'm currently stuck at this point.
Solution:
it should look like this ```php <?php namespace App\Enums;...
Jump to solution
3 Replies
tuto1902
tuto190211mo ago
can you share the code inside the app/Enums/AppointmentStatus.php file?
Solution
tuto1902
tuto190211mo ago
it should look like this
<?php

namespace App\Enums;

use Filament\Support\Contracts\HasColor;
use Filament\Support\Contracts\HasLabel;

enum AppointmentStatus: string implements HasLabel, HasColor
{
case Created = 'created';
case Confirmed = 'confirmed';
case Canceled = 'canceled';

public function getLabel(): ?string
{
return match($this) {
self::Created => 'Created',
self::Confirmed => 'Confirmed',
self::Canceled => 'Canceled',
};
}

public function getColor(): string | array | null
{
return match ($this) {
self::Created => 'warning',
self::Confirmed => 'success',
self::Canceled => 'danger',
};
}
}
<?php

namespace App\Enums;

use Filament\Support\Contracts\HasColor;
use Filament\Support\Contracts\HasLabel;

enum AppointmentStatus: string implements HasLabel, HasColor
{
case Created = 'created';
case Confirmed = 'confirmed';
case Canceled = 'canceled';

public function getLabel(): ?string
{
return match($this) {
self::Created => 'Created',
self::Confirmed => 'Confirmed',
self::Canceled => 'Canceled',
};
}

public function getColor(): string | array | null
{
return match ($this) {
self::Created => 'warning',
self::Confirmed => 'success',
self::Canceled => 'danger',
};
}
}
tuto1902
tuto190211mo ago
pay close attention to the namespace line. That's usually the problem when classes are not found
Want results from more Discord servers?
Add your server
More Posts