mirror of
https://github.com/pterodactyl/panel.git
synced 2026-11-30 11:25:52 -05:00
Co-authored-by: Anthony <anthony@infraly.co> Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
28 lines
533 B
PHP
28 lines
533 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Pterodactyl\Models\Traits;
|
|
|
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Pterodactyl\Facades\Hashids;
|
|
|
|
/**
|
|
* Expose the model's primary key as a hashid encoded string.
|
|
*
|
|
* @property-read string $hashid
|
|
*
|
|
* @mixin Model
|
|
*/
|
|
trait HasHashid
|
|
{
|
|
/**
|
|
* @return Attribute<string, never>
|
|
*/
|
|
protected function hashid(): Attribute
|
|
{
|
|
return Attribute::get(fn (): string => Hashids::encode($this->getKey()));
|
|
}
|
|
}
|