Created API endpoints
This commit is contained in:
28
app/Http/Resources/QuestionnaireResource.php
Normal file
28
app/Http/Resources/QuestionnaireResource.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\Resource;
|
||||
|
||||
class QuestionnaireResource extends Resource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
// return parent::toArray($request);
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'category' => new CategoryResource($this->category),
|
||||
'title' => $this->title,
|
||||
'description' => $this->description,
|
||||
'links' => [
|
||||
'self' => route('questionnaires.show', ['questionnaires' => $this->id])
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user