- Added local scopes for Enum-based fields (status, type, decision) in models: Cooperation, VerificationRequest, PartnerMedia, CooperationProposal, CooperationMedia, and VerificationReview. - Refactored query logic in Commands, Services, and Filament Resources to use the new scopes for better readability and maintainability. - Added specific pivot status scopes in PartnerMedia model for cleaner relationship filtering. - Fixed incorrect Enum usage in ViewCooperation.php during the refactoring process. - Standardized code style for closures and string concatenation in the modified files.
53 lines
1.2 KiB
PHP
53 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Enums\DecisionAdmin;
|
|
use Illuminate\Database\Eloquent\Attributes\Scope;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class VerificationReview extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $guarded = ['id'];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'decision' => DecisionAdmin::class,
|
|
];
|
|
}
|
|
|
|
#[Scope]
|
|
protected function approved(Builder $query): void
|
|
{
|
|
$query->where('decision', DecisionAdmin::APPROVED);
|
|
}
|
|
|
|
#[Scope]
|
|
protected function needRevision(Builder $query): void
|
|
{
|
|
$query->where('decision', DecisionAdmin::NEED_REVISION);
|
|
}
|
|
|
|
#[Scope]
|
|
protected function rejected(Builder $query): void
|
|
{
|
|
$query->where('decision', DecisionAdmin::REJECTED);
|
|
}
|
|
|
|
public function verificationRequest(): BelongsTo
|
|
{
|
|
return $this->belongsTo(VerificationRequest::class);
|
|
}
|
|
|
|
public function reviewer(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'reviewer_id');
|
|
}
|
|
}
|