feat: ship creator journey v2 and profile updates
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Services\ArtworkEvolutionService;
|
||||
use App\Services\ContentSanitizer;
|
||||
use App\Services\Maturity\ArtworkMaturityService;
|
||||
use App\Services\ThumbnailPresenter;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
@@ -97,11 +99,11 @@ class ArtworkResource extends JsonResource
|
||||
->exists();
|
||||
}
|
||||
|
||||
if (Schema::hasTable('artwork_awards')) {
|
||||
$viewerAward = DB::table('artwork_awards')
|
||||
if (Schema::hasTable('artwork_medals')) {
|
||||
$viewerAward = DB::table('artwork_medals')
|
||||
->where('user_id', $viewerId)
|
||||
->where('artwork_id', (int) $this->id)
|
||||
->value('medal');
|
||||
->value('medal_type');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,8 +227,24 @@ class ArtworkResource extends JsonResource
|
||||
'silver' => (int) ($this->awardStat?->silver_count ?? 0),
|
||||
'bronze' => (int) ($this->awardStat?->bronze_count ?? 0),
|
||||
'score' => (int) ($this->awardStat?->score_total ?? 0),
|
||||
'score_7d' => (int) ($this->awardStat?->score_7d ?? 0),
|
||||
'score_30d' => (int) ($this->awardStat?->score_30d ?? 0),
|
||||
'last_medaled_at' => optional($this->awardStat?->last_medaled_at)->toIsoString(),
|
||||
'viewer_award' => $viewerAward,
|
||||
],
|
||||
'medals' => [
|
||||
'gold' => (int) ($this->awardStat?->gold_count ?? 0),
|
||||
'silver' => (int) ($this->awardStat?->silver_count ?? 0),
|
||||
'bronze' => (int) ($this->awardStat?->bronze_count ?? 0),
|
||||
'score' => (int) ($this->awardStat?->score_total ?? 0),
|
||||
'score_7d' => (int) ($this->awardStat?->score_7d ?? 0),
|
||||
'score_30d' => (int) ($this->awardStat?->score_30d ?? 0),
|
||||
'last_medaled_at' => optional($this->awardStat?->last_medaled_at)->toIsoString(),
|
||||
'current_user_medal' => $viewerAward,
|
||||
'viewer_award' => $viewerAward,
|
||||
],
|
||||
'maturity' => app(ArtworkMaturityService::class)->presentation($this->resource, $request->user()),
|
||||
'evolution' => app(ArtworkEvolutionService::class)->publicPayload($this->resource, $request->user()),
|
||||
'categories' => $this->categories->map(fn ($category) => [
|
||||
'id' => (int) $category->id,
|
||||
'slug' => (string) $category->slug,
|
||||
|
||||
Reference in New Issue
Block a user