Use new attribute casting

This commit is contained in:
Lance Pioch 2022-10-24 12:01:26 -04:00
parent e49ba65709
commit 8a526539be
7 changed files with 88 additions and 80 deletions

View file

@ -5,6 +5,7 @@ namespace Pterodactyl\Models;
use Cron\CronExpression;
use Carbon\CarbonImmutable;
use Illuminate\Container\Container;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Pterodactyl\Contracts\Extensions\HashidsInterface;
@ -133,9 +134,11 @@ class Schedule extends Model
/**
* Return a hashid encoded string to represent the ID of the schedule.
*/
public function getHashidAttribute(): string
public function hashid(): Attribute
{
return Container::getInstance()->make(HashidsInterface::class)->encode($this->id);
return Attribute::make(
get: fn () => Container::getInstance()->make(HashidsInterface::class)->encode($this->id),
);
}
/**