30 lines
724 B
PHP
30 lines
724 B
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use Illuminate\Http\Resources\Json\Resource;
|
|
|
|
class QuestionResource extends Resource
|
|
{
|
|
/**
|
|
* Transform the resource collection into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request
|
|
* @return array
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
// return parent::toArray($request);
|
|
return [
|
|
'id' => $this->id,
|
|
'text' => $this->text,
|
|
'number' => $this->number,
|
|
'description' => $this->description,
|
|
'section' => new SectionResource($this->section),
|
|
'links' => [
|
|
'self' => route('questions.show', ['questions' => $this->id])
|
|
]
|
|
];
|
|
}
|
|
}
|