feat: subscriptions
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\IdentityVerificationStatus;
|
||||
use Illuminate\Database\Eloquent\Concerns\HasUlids;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class IdentityVerificationRequest extends Model
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\IdentityVerificationRequestFactory> */
|
||||
use HasFactory, HasUlids;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'status',
|
||||
'document_disk',
|
||||
'document_path',
|
||||
'document_mime_type',
|
||||
'document_size',
|
||||
'submitted_at',
|
||||
'reviewed_at',
|
||||
'reviewed_by',
|
||||
'rejection_reason',
|
||||
'document_deleted_at',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'document_disk',
|
||||
'document_path',
|
||||
];
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function reviewer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'reviewed_by');
|
||||
}
|
||||
|
||||
public function hasDocument(): bool
|
||||
{
|
||||
return filled($this->document_path) && $this->document_deleted_at === null;
|
||||
}
|
||||
|
||||
public function temporaryDocumentUrl(): ?string
|
||||
{
|
||||
if (! $this->hasDocument()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return Storage::disk($this->document_disk)->temporaryUrl(
|
||||
$this->document_path,
|
||||
now()->addMinutes((int) config('billing.identity_verification.temporary_url_minutes', 5)),
|
||||
);
|
||||
}
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'status' => IdentityVerificationStatus::class,
|
||||
'submitted_at' => 'datetime',
|
||||
'reviewed_at' => 'datetime',
|
||||
'document_deleted_at' => 'datetime',
|
||||
'document_size' => 'integer',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user