rbrecruiter/app/Http/Resources/ResponseResource.php

29 lines
748 B
PHP
Raw Permalink Normal View History

2021-03-31 02:55:09 +00:00
<?php
namespace App\Http\Resources;
use App\Form;
use App\Vacancy;
use Illuminate\Http\Resources\Json\JsonResource;
class ResponseResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'form' => new FormResource(Form::findOrFail($this->responseFormID)),
'responseData' => json_decode($this->responseData),
'vacancy' => new VacancyResource(Vacancy::findOrFail($this->associatedVacancyID)),
'created_at' => $this->created_at,
'updated_at' => $this->updated_at
];
}
}