generated from liutk/owl-admin-base
40 lines
1.0 KiB
PHP
40 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources\Api;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
use Illuminate\Http\Response;
|
|
|
|
class UserActivityResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
return [
|
|
'user_id' => $this->user_id,
|
|
'nick_name' => $this->whenLoaded('user', function () {
|
|
return $this->user?->nick_name ?? '';
|
|
}, ''),
|
|
'avatar' => $this->whenLoaded('user', function () {
|
|
return $this->user?->avatar ?? '';
|
|
}, ''),
|
|
|
|
'join_times' => $this->join_times,
|
|
'right_times' => $this->right_times,
|
|
'mark' => $this->mark,
|
|
'has_gift' => $this->has_gift,
|
|
|
|
'activity' => ActivityResource::make($this->whenLoaded('activity'))
|
|
];
|
|
}
|
|
|
|
public function with($request)
|
|
{
|
|
return ['code' => Response::HTTP_OK, 'message' => ''];
|
|
}
|
|
} |