You have to use Resource Collection to do that.
This public static $wrap = 'modules'; only works when
return new ModulesResource(Module::active()->first());
To do: ModuleCollection
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\ResourceCollection;
use App\Http\Resources\ModulesResource; // replace the name with your resource
class ModuleCollection extends ResourceCollection
{
/**
* Transform the resource collection into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public static $wrap = "modules";
public function toArray($request)
{
return ModulesResource::collection($this->collection);
}
}
https://laravel.com/docs/7.x/eloquent-resources#resource-collections