Может кто-нибудь объяснить разницу между ResourceCollection и JsonResource?
В документах Laravel 6 вы можете сгенерировать 2 разных типа ресурсов ... ResourceCollection и JsonResource. https://laravel.com/docs/6.x/eloquent-resources#resource-responses
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\ResourceCollection;
class ShopCollection extends ResourceCollection
{
/**
* Transform the resource collection into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return parent::toArray($request);
}
}
vs ...
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class Shop extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return parent::toArray($request);
}
}