Created API endpoints

This commit is contained in:
2017-12-20 16:45:20 +07:00
parent ad11643854
commit 554c74481b
53 changed files with 4637 additions and 9 deletions

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\Resource;
class AnswerResource extends Resource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'choice' => $this->questionchoice,
'text' => $this->text,
'links' => [
'self' => route('answers.show', ['answers' => $this->id]),
'relatedTo' => [
'question' => route('questions.show', ['questions' => $this->question_id]),
'respondent' => route('respondents.show', ['respondents' => $this->respondent_id])
]
]
];
}
}