generated from liutk/owl-admin-base
43 lines
1.5 KiB
PHP
43 lines
1.5 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' => $this->state < 2 ? now()->gte($this->game_at) : true,
|
||
'mark' => $this->mark,
|
||
'score_type' => $this->score_type ?? 1,//1为猜比分,2为猜胜负
|
||
'game_score' => $this->score,
|
||
'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' => ''];
|
||
}
|
||
} |