mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-22 03:56:42 +00:00
56 lines
1.2 KiB
PHP
56 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace FireflyIII\JsonApi\V2\Users;
|
|
|
|
use FireflyIII\User;
|
|
use LaravelJsonApi\Eloquent\Contracts\Paginator;
|
|
use LaravelJsonApi\Eloquent\Fields\DateTime;
|
|
use LaravelJsonApi\Eloquent\Fields\ID;
|
|
use LaravelJsonApi\Eloquent\Fields\Relations\HasMany;
|
|
use LaravelJsonApi\Eloquent\Fields\Str;
|
|
use LaravelJsonApi\Eloquent\Filters\WhereIdIn;
|
|
use LaravelJsonApi\Eloquent\Pagination\PagePagination;
|
|
use LaravelJsonApi\Eloquent\Schema;
|
|
|
|
class UserSchema extends Schema
|
|
{
|
|
/**
|
|
* The model the schema corresponds to.
|
|
*/
|
|
public static string $model = User::class;
|
|
|
|
/**
|
|
* Get the resource fields.
|
|
*/
|
|
public function fields(): array
|
|
{
|
|
return [
|
|
ID::make(),
|
|
DateTime::make('created_at')->sortable()->readOnly(),
|
|
DateTime::make('updated_at')->sortable()->readOnly(),
|
|
Str::make('email'),
|
|
HasMany::make('accounts'),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Get the resource filters.
|
|
*/
|
|
public function filters(): array
|
|
{
|
|
return [
|
|
WhereIdIn::make($this),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Get the resource paginator.
|
|
*/
|
|
public function pagination(): ?Paginator
|
|
{
|
|
return PagePagination::make();
|
|
}
|
|
}
|