July 2018
Intermediate to advanced
420 pages
8h 46m
English
So, let's create our first resource:
php artisan make:resource BikesResource
The previous command will generate the following file:
App\Http\Resource\BikesResource.php.
<?phpnamespace App\Http\Resources;use Illuminate\Http\Resources\Json\JsonResource;use App\Builder;class BikesResource extends JsonResource{ /** * Transform the resource into an array. * * @param \Illuminate\Http\Request $request * @return array */ public function toArray($request) { return [ 'id' => $this->id, 'make' => $this->make, 'model' => $this->model, 'year' => $this->year, 'mods' => $this->mods, 'picture' => $this->picture, ...Read now
Unlock full access