- Make all tests pass Client (V4),CRMV2,CRMV4 - Simplify client submodule path - Move App_url to .env.testing
35 lines
1.2 KiB
PHP
35 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources\Api\V2;
|
|
|
|
use App\Models\BrandStat;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\ResourceCollection as JsonResourceCollection;
|
|
|
|
class BrandStatsResource extends JsonResourceCollection
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array
|
|
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
|
|
*/
|
|
public function toArray(Request $request): array
|
|
{
|
|
//phpcs:enable
|
|
return [
|
|
'stats' => $this->collection->map(function (BrandStat $brandStat) {
|
|
return [
|
|
'date' => $brandStat->created_at->isoFormat('YYYY-MM-DD'),
|
|
'active' => $brandStat->active,
|
|
'inactive' => $brandStat->inactive,
|
|
'old_accounts' => $brandStat->old_accounts,
|
|
'new_accounts' => $brandStat->new_accounts,
|
|
'total_accounts' => $brandStat->total_accounts,
|
|
'total_opt_in' => $brandStat->total_opt_in
|
|
];
|
|
})
|
|
];
|
|
}
|
|
}
|