Build world campaigns rewards and recaps

This commit is contained in:
2026-05-01 11:44:41 +02:00
parent 28e7e46e13
commit 257b0dbef6
100 changed files with 11300 additions and 367 deletions

View File

@@ -0,0 +1,89 @@
<?php
declare(strict_types=1);
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class GroupChallengeOutcome extends Model
{
use HasFactory;
public const TYPE_WINNER = 'winner';
public const TYPE_FINALIST = 'finalist';
public const TYPE_RUNNER_UP = 'runner_up';
public const TYPE_HONORABLE_MENTION = 'honorable_mention';
public const TYPE_FEATURED = 'featured';
protected $fillable = [
'group_challenge_id',
'artwork_id',
'user_id',
'outcome_type',
'position',
'sort_order',
'title_override',
'note',
'awarded_by_user_id',
'awarded_at',
];
protected function casts(): array
{
return [
'group_challenge_id' => 'integer',
'artwork_id' => 'integer',
'user_id' => 'integer',
'position' => 'integer',
'sort_order' => 'integer',
'awarded_by_user_id' => 'integer',
'awarded_at' => 'datetime',
];
}
public static function supportedTypes(): array
{
return [
self::TYPE_WINNER,
self::TYPE_FINALIST,
self::TYPE_RUNNER_UP,
self::TYPE_HONORABLE_MENTION,
self::TYPE_FEATURED,
];
}
public static function labelForType(string $type): string
{
return match ($type) {
self::TYPE_WINNER => 'Winner',
self::TYPE_FINALIST => 'Finalist',
self::TYPE_RUNNER_UP => 'Runner-up',
self::TYPE_HONORABLE_MENTION => 'Honorable Mention',
self::TYPE_FEATURED => 'Featured',
default => ucwords(str_replace('_', ' ', $type)),
};
}
public function challenge(): BelongsTo
{
return $this->belongsTo(GroupChallenge::class, 'group_challenge_id');
}
public function artwork(): BelongsTo
{
return $this->belongsTo(Artwork::class);
}
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
public function awardedBy(): BelongsTo
{
return $this->belongsTo(User::class, 'awarded_by_user_id');
}
}