generated from liutk/owl-admin-base
41 lines
1.3 KiB
PHP
41 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources\Api;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
use Illuminate\Http\Response;
|
|
|
|
class ActivityGameResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'activity_id' => $this->activity_id,
|
|
'name' => $this->name,
|
|
'home_field' => $this->home_field ??'',
|
|
'home_logo' => $this->home_logo ??'',
|
|
'away' => $this->away ??'',
|
|
'away_logo' => $this->away_logo ??'',
|
|
'game_at' => $this->game_at->format('Y-m-d H:i'),
|
|
'little_game_at' => $this->game_at->format('H:i'),
|
|
'game_day' => $this->game_at->format('Y-m-d'),
|
|
'game_at_comparison_now' => now()->gte($this->game_at),
|
|
'mark' => $this->mark,
|
|
'has_guess' => !$this->logs->isEmpty() ? ($this->logs[0]->score):false,
|
|
'has_guess_right' => !$this->logs->isEmpty() ? ($this->logs[0]->is_right):false,
|
|
'state' => $this->state,
|
|
];
|
|
}
|
|
|
|
public function with($request)
|
|
{
|
|
return ['code' => Response::HTTP_OK, 'message' => ''];
|
|
}
|
|
} |