Files
nexusphp/app/Http/Resources/ExamUserResource.php
xiaomlove 0c5f3d935d exam-user
2021-04-25 02:12:14 +08:00

31 lines
737 B
PHP

<?php
namespace App\Http\Resources;
use App\Models\Exam;
use App\Models\User;
use Carbon\Carbon;
use Illuminate\Http\Resources\Json\JsonResource;
class ExamUserResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'status' => $this->status,
'status_text' => $this->statusText,
'created_at' => $this->created_at->format('Y-m-d H:i:s'),
'user' => new UserResource($this->whenLoaded('user')),
'exam' => new ExamResource($this->whenLoaded('exam')),
];
}
}