'array', 'expires_at' => 'datetime', ]; public function scopeForBusiness($query, int $businessId) { return $query->where('business_id', $businessId); } public function scopeValid($query) { return $query->where(function ($q) { $q->whereNull('expires_at') ->orWhere('expires_at', '>', now()); }); } public function isExpired(): bool { return $this->expires_at !== null && $this->expires_at->isPast(); } public function hasScope(string $dataset): bool { $scopes = $this->scopes ?? []; return in_array('*', $scopes, true) || in_array($dataset, $scopes, true); } public static function hashToken(string $plainToken): string { return hash('sha256', $plainToken); } public static function generatePlainToken(): string { return 'ih_'.Str::random(48); } }