Build world campaigns rewards and recaps
This commit is contained in:
65
app/Models/WorldRewardGrant.php
Normal file
65
app/Models/WorldRewardGrant.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\WorldRewardType;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class WorldRewardGrant extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'world_id',
|
||||
'artwork_id',
|
||||
'world_submission_id',
|
||||
'granted_by_user_id',
|
||||
'reward_type',
|
||||
'grant_source',
|
||||
'note',
|
||||
'granted_at',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'user_id' => 'integer',
|
||||
'world_id' => 'integer',
|
||||
'artwork_id' => 'integer',
|
||||
'world_submission_id' => 'integer',
|
||||
'granted_by_user_id' => 'integer',
|
||||
'reward_type' => WorldRewardType::class,
|
||||
'granted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id');
|
||||
}
|
||||
|
||||
public function world(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(World::class);
|
||||
}
|
||||
|
||||
public function artwork(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Artwork::class);
|
||||
}
|
||||
|
||||
public function worldSubmission(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(WorldSubmission::class, 'world_submission_id');
|
||||
}
|
||||
|
||||
public function grantedBy(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'granted_by_user_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user