|QuoteAuthorization approved() * @method static \Illuminate\Database\Eloquent\Builder|QuoteAuthorization newModelQuery() * @method static \Illuminate\Database\Eloquent\Builder|QuoteAuthorization newQuery() * @method static \Illuminate\Database\Eloquent\Builder|QuoteAuthorization query() * @method static \Illuminate\Database\Eloquent\Builder|QuoteAuthorization revoked() * * @mixin \Eloquent */ class QuoteAuthorization extends Model { use HasSnowflakePrimary; public const STATE_APPROVED = 'approved'; public const STATE_REVOKED = 'revoked'; public $incrementing = false; protected $keyType = 'int'; protected $guarded = []; protected function casts(): array { return [ 'revoked_at' => 'datetime', ]; } /** * The local profile whose post was quoted. */ public function profile(): BelongsTo { return $this->belongsTo(Profile::class, 'profile_id'); } /** * The local post that was quoted. */ public function status(): BelongsTo { return $this->belongsTo(Status::class, 'status_id'); } /** * The remote profile that authored the quote post. */ public function actor(): BelongsTo { return $this->belongsTo(Profile::class, 'actor_id'); } public function isApproved(): bool { return $this->state === self::STATE_APPROVED; } public function isRevoked(): bool { return $this->state === self::STATE_REVOKED; } /** * Public URL of the stamp. Must share a host with the quoted author's * actor id, which remote servers check during verification. */ public function permalink(): string { return $this->profile->permalink('/quote_authorizations/'.$this->id); } public function scopeApproved($query) { return $query->where('state', self::STATE_APPROVED); } public function scopeRevoked($query) { return $query->where('state', self::STATE_REVOKED); } }