mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-15 05:00:49 +08:00
medal management
This commit is contained in:
31
app/Http/Resources/MedalResource.php
Normal file
31
app/Http/Resources/MedalResource.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class MedalResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'get_type' => $this->get_type,
|
||||
'get_type_text' => $this->getTypeText,
|
||||
'image_large' => $this->image_large,
|
||||
'image_small' => $this->image_small,
|
||||
'price' => $this->price,
|
||||
'duration' => $this->duration,
|
||||
'description' => $this->description,
|
||||
'expire_at' => $this->whenPivotLoaded('user_medals', function () {return $this->pivot->expire_at;}),
|
||||
'user_medal_id' => $this->whenPivotLoaded('user_medals', function () {return $this->pivot->id;}),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@ class UserResource extends JsonResource
|
||||
'leechtime' => $this->leechtime,
|
||||
'leechtime_text' => mkprettytime($this->leechtime),
|
||||
'inviter' => new UserResource($this->whenLoaded('inviter')),
|
||||
'valid_medals' => MedalResource::collection($this->whenLoaded('valid_medals')),
|
||||
];
|
||||
if ($request->routeIs('user.me')) {
|
||||
$out['downloaded_human'] = mksize($this->downloaded);
|
||||
|
||||
Reference in New Issue
Block a user