Created API endpoints
This commit is contained in:
29
app/Http/Resources/QuestionResource.php
Normal file
29
app/Http/Resources/QuestionResource.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?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])
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user