July 2018
Intermediate to advanced
420 pages
8h 46m
English
Now, let's create ItemsResource using the make command:
php artisan make:resource ItemsResource
<?phpnamespace App\Http\Resources;use Illuminate\Http\Resources\Json\JsonResource;class ItemsResource extends JsonResource{ /** * Transform the resource into an array. * * @param \Illuminate\Http\Request $request * @return array */ public function toArray($request) { return [ 'id' => $this->id, 'type' => $this->type, 'name' => $this->name, 'company' => $this->company, 'bike_id' => $this->bike_id, // Casting ...Read now
Unlock full access