This commit is contained in:
Codex
2026-07-10 11:18:07 -05:00
parent 42db078e47
commit e5a95a0687
32 changed files with 471 additions and 11 deletions
+5
View File
@@ -23,4 +23,9 @@ class BuyerProfile extends Model
{
return $this->morphMany(Attachment::class, 'attachable');
}
public function ratings(): MorphMany
{
return $this->morphMany(Rating::class, 'rateable');
}
}
+5
View File
@@ -46,4 +46,9 @@ class Dispute extends Model
{
return $this->morphMany(Attachment::class, 'attachable');
}
public function ratings(): MorphMany
{
return $this->morphMany(Rating::class, 'rateable');
}
}
+5
View File
@@ -47,4 +47,9 @@ class JobPost extends Model
{
return $this->morphMany(Attachment::class, 'attachable');
}
public function ratings(): MorphMany
{
return $this->morphMany(Rating::class, 'rateable');
}
}
+5
View File
@@ -29,4 +29,9 @@ class ProviderProfile extends Model
{
return $this->morphMany(Attachment::class, 'attachable');
}
public function ratings(): MorphMany
{
return $this->morphMany(Rating::class, 'rateable');
}
}
+30
View File
@@ -0,0 +1,30 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\MorphTo;
use Illuminate\Database\Eloquent\Model;
#[Fillable(['user_id', 'category', 'stars', 'thumbs_up', 'body'])]
class Rating extends Model
{
protected function casts(): array
{
return [
'stars' => 'integer',
'thumbs_up' => 'boolean',
];
}
public function rateable(): MorphTo
{
return $this->morphTo();
}
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
}
+5
View File
@@ -85,6 +85,11 @@ class WorkOrder extends Model
return $this->morphMany(Attachment::class, 'attachable');
}
public function ratings(): MorphMany
{
return $this->morphMany(Rating::class, 'rateable');
}
public function canTransitionTo(string $status): bool
{
return in_array($status, self::ALLOWED_TRANSITIONS[$this->status] ?? [], true);