Created
April 25, 2020 16:32
-
-
Save siljanoskam/e0e30203405aab2c683bd233b50e2f4b to your computer and use it in GitHub Desktop.
Resources
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Resources; | |
use Illuminate\Http\Request; | |
use Illuminate\Http\Resources\Json\JsonResource; | |
class Task extends JsonResource | |
{ | |
/** | |
* Transform the resource into an array. | |
* | |
* @param Request $request | |
* @return array | |
*/ | |
public function toArray($request) | |
{ | |
return [ | |
'id' => $this->id, | |
'title' => $this->title, | |
'description' => $this->description, | |
'date' => $this->date, | |
'status' => $this->status, | |
'user_id' => $this->user_id | |
]; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Resources; | |
use Illuminate\Http\Request; | |
use Illuminate\Http\Resources\Json\JsonResource; | |
class User extends JsonResource | |
{ | |
/** | |
* Transform the resource into an array. | |
* | |
* @param Request $request | |
* @return array | |
*/ | |
public function toArray($request) | |
{ | |
return [ | |
'id' => $this->id, | |
'name' => $this->name, | |
'email' => $this->email | |
]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment