*/ use HasFactory, OwnedByUser; /** * @return array */ protected function casts(): array { return [ // Encrypted (not hashed) so the owner can re-read it and the ZIP // can be AES-encrypted with the same password on download. 'password' => 'encrypted', 'expires_at' => 'datetime', 'revoked_at' => 'datetime', 'last_accessed_at' => 'datetime', ]; } /** * @return BelongsToMany */ public function certificates(): BelongsToMany { return $this->belongsToMany(Certificate::class); } public function isActive(): bool { return $this->revoked_at === null && $this->expires_at->isFuture(); } public function url(): string { return route('shared.show', $this->token); } public function recordAccess(): void { $this->increment('access_count', extra: ['last_accessed_at' => now()]); } }