Skip to content

Open-source event management and ticket selling platform — perfect for concerts, conferences, and everything in between 🎟️ If you find this project helpful, please consider giving us a star ⭐️

1008 B
Raw Blame
<?php

declare(strict_types=1);

namespace HiEvents\Resources\Affiliate;

use HiEvents\DomainObjects\AffiliateDomainObject;
use HiEvents\DomainObjects\Enums\Permission;
use HiEvents\Resources\BaseResource;
use Illuminate\Http\Request;

/**
 * @mixin AffiliateDomainObject
 */
class AffiliateResource extends BaseResource
{
    public function toArray(Request $request): array
    {
        return [
            'id' => $this->getId(),
            'event_id' => $this->getEventId(),
            'account_id' => $this->getAccountId(),
            'name' => $this->getName(),
            'code' => $this->getCode(),
            'email' => $this->getEmail(),
            'total_sales' => $this->getTotalSales(),
            'total_sales_gross' => $this->when($this->isPermitted(Permission::VIEW_FINANCIALS), fn () => $this->getTotalSalesGross()),
            'status' => $this->getStatus(),
            'created_at' => $this->getCreatedAt(),
            'updated_at' => $this->getUpdatedAt(),
        ];
    }
}