EscolaLMS/Auth

View on GitHub
src/Http/Resources/UserSettingResource.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace EscolaLms\Auth\Http\Resources;

use EscolaLms\Auth\Models\UserSetting;
use Illuminate\Http\Resources\Json\JsonResource;
use EscolaLms\Auth\Traits\ResourceExtandable;

class UserSettingResource extends JsonResource
{
    use ResourceExtandable;

    public function __construct(UserSetting $resource)
    {
        parent::__construct($resource);
    }

    public function toArray($request)
    {
        /** @var UserSetting $resource */
        $resource = $this->resource;
        $fields = [
            $resource->key => $resource->value
        ];

        return self::apply($fields, $this);
    }
}