File: D:/HostingSpaces/SBogers10/shop.komma.nl/app/Properties/Resources/Property.php
<?php
namespace App\Properties\Resources;
use App\Properties\Models\Property as PropertyModel;
use Illuminate\Http\Resources\Json\JsonResource;
use Komma\KMS\Core\Entities\DisplayNameTrait;
/**
* Class Property
*
* @mixin PropertyModel
* @package App\Properties\Resources
*/
class Property extends JsonResource
{
use DisplayNameTrait;
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'is_required' => $this->is_required ?? false,
'state' => $this->state,
'propertizable_id' => $this->propertizable_id ?? -1,
'propertizable_type' => $this->propertizable_type ?? '',
'key' => new Key($this->key),
'values' => Value::collection($this->values)
];
}
}