Skip to content

Commit

Permalink
Created and added the assignment resource
Browse files Browse the repository at this point in the history
Signed-off-by: WillTheDeveloper <willthedeveloper13@gmail.com>
  • Loading branch information
WillTheDeveloper committed Sep 25, 2022
1 parent 89bbb8e commit fd3be61
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/Http/Resources/AssignmentResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ class AssignmentResource extends JsonResource
*/
public function toArray($request)
{
return parent::toArray($request);
return [
'title' => $this->title,
'details' => $this->details,
'due' => $this->duedate,
'set' => $this->setdate,
'subject' => $this->Subject->subject,
'created' => $this->created_at
];
}
}
4 changes: 4 additions & 0 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@

Route::get('/comment/{id}', function ($id) {
return new \App\Http\Resources\CommentResource(\App\Models\Comment::findOrFail($id));
});

Route::get('/assignment/{id}', function ($id) {
return new \App\Http\Resources\AssignmentResource(\App\Models\Assignment::findOrFail($id));
});

0 comments on commit fd3be61

Please sign in to comment.