mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-11-21 16:38:36 -06:00
Various API changes for v2
This commit is contained in:
parent
ad3b0bb320
commit
077f3e095b
@ -2,10 +2,10 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Api\V3\Controllers;
|
||||
namespace FireflyIII\Http\Controllers\Api\V2\Controllers;
|
||||
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\JsonApi\V3\AccountBalances\AccountBalanceSchema;
|
||||
use FireflyIII\JsonApi\V2\AccountBalances\AccountBalanceSchema;
|
||||
use FireflyIII\Models\Account;
|
||||
use Illuminate\Contracts\Support\Responsable;
|
||||
use LaravelJsonApi\Core\Facades\JsonApi;
|
||||
@ -26,18 +26,18 @@ class AccountController extends Controller
|
||||
use Actions\Update;
|
||||
use Actions\UpdateRelationship;
|
||||
|
||||
public function readAccountBalances(AnonymousQuery $query, AccountBalanceSchema $schema, Account $account): Responsable
|
||||
{
|
||||
$schema = JsonApi::server()->schemas()->schemaFor('account-balances');
|
||||
|
||||
$models = $schema
|
||||
->repository()
|
||||
->queryAll()
|
||||
->withRequest($query)
|
||||
->withAccount($account)
|
||||
->get()
|
||||
;
|
||||
|
||||
return DataResponse::make($models);
|
||||
}
|
||||
// public function readAccountBalances(AnonymousQuery $query, AccountBalanceSchema $schema, Account $account): Responsable
|
||||
// {
|
||||
// $schema = JsonApi::server()->schemas()->schemaFor('account-balances');
|
||||
//
|
||||
// $models = $schema
|
||||
// ->repository()
|
||||
// ->queryAll()
|
||||
// ->withRequest($query)
|
||||
// ->withAccount($account)
|
||||
// ->get()
|
||||
// ;
|
||||
//
|
||||
// return DataResponse::make($models);
|
||||
// }
|
||||
}
|
@ -21,7 +21,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\JsonApi\V3\AccountBalances;
|
||||
namespace FireflyIII\JsonApi\V2\AccountBalances;
|
||||
|
||||
use FireflyIII\Entities\AccountBalance;
|
||||
use LaravelJsonApi\Contracts\Store\QueriesAll;
|
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\JsonApi\V3\AccountBalances;
|
||||
namespace FireflyIII\JsonApi\V2\AccountBalances;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use LaravelJsonApi\Core\Resources\JsonApiResource;
|
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\JsonApi\V3\AccountBalances;
|
||||
namespace FireflyIII\JsonApi\V2\AccountBalances;
|
||||
|
||||
use FireflyIII\Entities\AccountBalance;
|
||||
use LaravelJsonApi\Core\Schema\Schema;
|
@ -21,7 +21,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\JsonApi\V3\AccountBalances\Capabilities;
|
||||
namespace FireflyIII\JsonApi\V2\AccountBalances\Capabilities;
|
||||
|
||||
use FireflyIII\Entities\AccountBalance;
|
||||
use FireflyIII\Models\Account;
|
@ -21,7 +21,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\JsonApi\V3\Accounts;
|
||||
namespace FireflyIII\JsonApi\V2\Accounts;
|
||||
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Support\JsonApi\Concerns\UsergroupAware;
|
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\JsonApi\V3\Accounts;
|
||||
namespace FireflyIII\JsonApi\V2\Accounts;
|
||||
|
||||
use FireflyIII\Models\Account;
|
||||
use Illuminate\Http\Request;
|
||||
@ -123,7 +123,8 @@ class AccountResource extends JsonApiResource
|
||||
{
|
||||
return [
|
||||
$this->relation('user')->withData($this->resource->user),
|
||||
$this->relation('account_balances')->withData($this->resource->balances),
|
||||
$this->relation('currency')->withData($this->resource->transactionCurrency),
|
||||
//$this->relation('account_balances')->withData($this->resource->balances),
|
||||
];
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\JsonApi\V3\Accounts;
|
||||
namespace FireflyIII\JsonApi\V2\Accounts;
|
||||
|
||||
use FireflyIII\Models\Account;
|
||||
use LaravelJsonApi\Eloquent\Contracts\Paginator;
|
@ -21,7 +21,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\JsonApi\V3\Accounts\Capabilities;
|
||||
namespace FireflyIII\JsonApi\V2\Accounts\Capabilities;
|
||||
|
||||
use FireflyIII\Support\JsonApi\Concerns\UsergroupAware;
|
||||
use FireflyIII\Support\JsonApi\Enrichments\AccountEnrichment;
|
@ -2,11 +2,11 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\JsonApi\V3;
|
||||
namespace FireflyIII\JsonApi\V2;
|
||||
|
||||
use FireflyIII\JsonApi\V3\Accounts\AccountSchema;
|
||||
use FireflyIII\JsonApi\V3\AccountBalances\AccountBalanceSchema;
|
||||
use FireflyIII\JsonApi\V3\Users\UserSchema;
|
||||
use FireflyIII\JsonApi\V2\Accounts\AccountSchema;
|
||||
use FireflyIII\JsonApi\V2\AccountBalances\AccountBalanceSchema;
|
||||
use FireflyIII\JsonApi\V2\Users\UserSchema;
|
||||
use LaravelJsonApi\Core\Server\Server as BaseServer;
|
||||
|
||||
class Server extends BaseServer
|
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\JsonApi\V3\Users;
|
||||
namespace FireflyIII\JsonApi\V2\Users;
|
||||
|
||||
use FireflyIII\Models\User;
|
||||
use Illuminate\Http\Request;
|
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\JsonApi\V3\Users;
|
||||
namespace FireflyIII\JsonApi\V2\Users;
|
||||
|
||||
use FireflyIII\User;
|
||||
use LaravelJsonApi\Eloquent\Contracts\Paginator;
|
@ -28,6 +28,7 @@ use Eloquent;
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
|
||||
use FireflyIII\User;
|
||||
use GeneaLabs\LaravelModelCaching\Traits\Cachable;
|
||||
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
@ -95,22 +96,22 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static Builder|Account withTrashed()
|
||||
* @method static Builder|Account withoutTrashed()
|
||||
*
|
||||
* @property Carbon $lastActivityDate
|
||||
* @property string $startBalance
|
||||
* @property string $endBalance
|
||||
* @property string $difference
|
||||
* @property string $interest
|
||||
* @property string $interestPeriod
|
||||
* @property string $accountTypeString
|
||||
* @property Location $location
|
||||
* @property string $liability_direction
|
||||
* @property string $current_debt
|
||||
* @property int $user_group_id
|
||||
* @property Carbon $lastActivityDate
|
||||
* @property string $startBalance
|
||||
* @property string $endBalance
|
||||
* @property string $difference
|
||||
* @property string $interest
|
||||
* @property string $interestPeriod
|
||||
* @property string $accountTypeString
|
||||
* @property Location $location
|
||||
* @property string $liability_direction
|
||||
* @property string $current_debt
|
||||
* @property int $user_group_id
|
||||
*
|
||||
* @method static EloquentBuilder|Account whereUserGroupId($value)
|
||||
*
|
||||
* @property null|UserGroup $userGroup
|
||||
* @property mixed $account_id
|
||||
* @property null|UserGroup $userGroup
|
||||
* @property mixed $account_id
|
||||
*
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
@ -120,9 +121,10 @@ class Account extends Model
|
||||
use ReturnsIntegerIdTrait;
|
||||
use ReturnsIntegerUserIdTrait;
|
||||
use SoftDeletes;
|
||||
use Cachable;
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
= [
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
'user_id' => 'integer',
|
||||
@ -131,9 +133,9 @@ class Account extends Model
|
||||
'encrypted' => 'boolean',
|
||||
];
|
||||
|
||||
protected $fillable = ['user_id', 'user_group_id', 'account_type_id', 'name', 'active', 'virtual_balance', 'iban'];
|
||||
protected $fillable = ['user_id', 'user_group_id', 'account_type_id', 'name', 'active', 'virtual_balance', 'iban'];
|
||||
|
||||
protected $hidden = ['encrypted'];
|
||||
protected $hidden = ['encrypted'];
|
||||
private bool $joinedAccountTypes = false;
|
||||
|
||||
/**
|
||||
@ -144,13 +146,13 @@ class Account extends Model
|
||||
public static function routeBinder(string $value): self
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$accountId = (int)$value;
|
||||
$accountId = (int) $value;
|
||||
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
$user = auth()->user();
|
||||
|
||||
/** @var null|Account $account */
|
||||
$account = $user->accounts()->with(['accountType'])->find($accountId);
|
||||
$account = $user->accounts()->with(['accountType'])->find($accountId);
|
||||
if (null !== $account) {
|
||||
return $account;
|
||||
}
|
||||
@ -181,9 +183,8 @@ class Account extends Model
|
||||
{
|
||||
/** @var null|AccountMeta $metaValue */
|
||||
$metaValue = $this->accountMeta()
|
||||
->where('name', 'account_number')
|
||||
->first()
|
||||
;
|
||||
->where('name', 'account_number')
|
||||
->first();
|
||||
|
||||
return null !== $metaValue ? $metaValue->data : '';
|
||||
}
|
||||
@ -246,7 +247,7 @@ class Account extends Model
|
||||
|
||||
public function setVirtualBalanceAttribute(mixed $value): void
|
||||
{
|
||||
$value = (string)$value;
|
||||
$value = (string) $value;
|
||||
if ('' === $value) {
|
||||
$value = null;
|
||||
}
|
||||
@ -266,7 +267,7 @@ class Account extends Model
|
||||
protected function accountId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn ($value) => (int)$value,
|
||||
get: static fn($value) => (int) $value,
|
||||
);
|
||||
}
|
||||
|
||||
@ -276,21 +277,21 @@ class Account extends Model
|
||||
protected function accountTypeId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn ($value) => (int)$value,
|
||||
get: static fn($value) => (int) $value,
|
||||
);
|
||||
}
|
||||
|
||||
protected function iban(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn ($value) => null === $value ? null : trim(str_replace(' ', '', (string)$value)),
|
||||
get: static fn($value) => null === $value ? null : trim(str_replace(' ', '', (string) $value)),
|
||||
);
|
||||
}
|
||||
|
||||
protected function order(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn ($value) => (int)$value,
|
||||
get: static fn($value) => (int) $value,
|
||||
);
|
||||
}
|
||||
|
||||
@ -300,7 +301,7 @@ class Account extends Model
|
||||
protected function virtualBalance(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn ($value) => (string)$value,
|
||||
get: static fn($value) => (string) $value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -84,6 +84,7 @@
|
||||
"bacon/bacon-qr-code": "2.*",
|
||||
"diglactic/laravel-breadcrumbs": "^9",
|
||||
"gdbots/query-parser": "^3.0",
|
||||
"genealabs/laravel-model-caching": "^11.0",
|
||||
"guzzlehttp/guzzle": "^7.8",
|
||||
"jc5/google2fa-laravel": "^2.0",
|
||||
"jc5/recovery": "^2",
|
||||
|
126
composer.lock
generated
126
composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "a3648ab093343dd83bf7e728034ab46c",
|
||||
"content-hash": "9d828d17b38cf563cd5cfc14c906c08f",
|
||||
"packages": [
|
||||
{
|
||||
"name": "bacon/bacon-qr-code",
|
||||
@ -1045,6 +1045,130 @@
|
||||
},
|
||||
"time": "2021-12-05T19:44:35+00:00"
|
||||
},
|
||||
{
|
||||
"name": "genealabs/laravel-model-caching",
|
||||
"version": "11.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/mikebronner/laravel-model-caching.git",
|
||||
"reference": "2a38f0f1ed3554cf2da272d66c4d08a7885f196b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/mikebronner/laravel-model-caching/zipball/2a38f0f1ed3554cf2da272d66c4d08a7885f196b",
|
||||
"reference": "2a38f0f1ed3554cf2da272d66c4d08a7885f196b",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"genealabs/laravel-pivot-events": "^10.0|^11.0",
|
||||
"illuminate/cache": "^10.0|^11.0",
|
||||
"illuminate/config": "^10.0|^11.0",
|
||||
"illuminate/console": "^10.0|^11.0",
|
||||
"illuminate/container": "^10.0|^11.0",
|
||||
"illuminate/database": "^10.0|^11.0",
|
||||
"illuminate/http": "^10.0|^11.0",
|
||||
"illuminate/support": "^10.0|^11.0",
|
||||
"php": ">=8.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/dbal": "^3.3",
|
||||
"fakerphp/faker": "^1.11",
|
||||
"laravel/legacy-factories": "^1.3",
|
||||
"laravel/nova": "^4.0",
|
||||
"orchestra/testbench": "^8.0|^9.0",
|
||||
"orchestra/testbench-browser-kit": "^8.0",
|
||||
"php-coveralls/php-coveralls": "^2.2",
|
||||
"phpunit/phpunit": "^10.0",
|
||||
"slevomat/coding-standard": "^7.0|^8.14",
|
||||
"squizlabs/php_codesniffer": "^3.6",
|
||||
"symfony/thanks": "^1.2"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"GeneaLabs\\LaravelModelCaching\\Providers\\Service"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"GeneaLabs\\LaravelModelCaching\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Mike Bronner",
|
||||
"email": "hello@genealabs.com"
|
||||
}
|
||||
],
|
||||
"description": "Automatic caching for Eloquent models.",
|
||||
"support": {
|
||||
"issues": "https://github.com/mikebronner/laravel-model-caching/issues",
|
||||
"source": "https://github.com/mikebronner/laravel-model-caching/tree/11.0.1"
|
||||
},
|
||||
"time": "2024-03-14T23:34:57+00:00"
|
||||
},
|
||||
{
|
||||
"name": "genealabs/laravel-pivot-events",
|
||||
"version": "11.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/mikebronner/laravel-pivot-events.git",
|
||||
"reference": "16e974d80160774641f4323f5ffb757b79f300d3"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/mikebronner/laravel-pivot-events/zipball/16e974d80160774641f4323f5ffb757b79f300d3",
|
||||
"reference": "16e974d80160774641f4323f5ffb757b79f300d3",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/database": "^8.0|^9.0|^10.0|^11.0",
|
||||
"illuminate/support": "^8.0|^9.0|^10.0|^11.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"orchestra/testbench": "^9.0",
|
||||
"phpunit/phpunit": "^10.5",
|
||||
"symfony/thanks": "^1.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"GeneaLabs\\LaravelPivotEvents\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Mike Bronner",
|
||||
"email": "hello@genealabs.com",
|
||||
"homepage": "https://genealabs.com",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "This package introduces new eloquent events for sync(), attach(), detach() or updateExistingPivot() methods on BelongsToMany relation.",
|
||||
"homepage": "https://github.com/mikebronner/laravel-pivot-events",
|
||||
"keywords": [
|
||||
"eloquent events",
|
||||
"eloquent extra events",
|
||||
"laravel BelongsToMany events",
|
||||
"laravel pivot events",
|
||||
"laravel sync events"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/mikebronner/laravel-pivot-events/issues",
|
||||
"source": "https://github.com/mikebronner/laravel-pivot-events"
|
||||
},
|
||||
"time": "2024-03-14T23:24:54+00:00"
|
||||
},
|
||||
{
|
||||
"name": "graham-campbell/result-type",
|
||||
"version": "v1.1.3",
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use FireflyIII\JsonApi\V3\Server;
|
||||
use FireflyIII\JsonApi\V2\Server;
|
||||
|
||||
return [
|
||||
/*
|
||||
@ -30,6 +30,6 @@ return [
|
||||
| class name of the server class.
|
||||
*/
|
||||
'servers' => [
|
||||
'v3' => Server::class,
|
||||
'v2' => Server::class,
|
||||
],
|
||||
];
|
||||
|
11
config/laravel-model-caching.php
Normal file
11
config/laravel-model-caching.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'cache-prefix' => '',
|
||||
|
||||
'enabled' => env('MODEL_CACHE_ENABLED', true),
|
||||
|
||||
'use-database-keying' => env('MODEL_CACHE_USE_DATABASE_KEYING', true),
|
||||
|
||||
'store' => env('MODEL_CACHE_STORE'),
|
||||
];
|
101
routes/api.php
101
routes/api.php
@ -22,14 +22,27 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use FireflyIII\Http\Controllers\Api\V3\Controllers\AccountController;
|
||||
use FireflyIII\Http\Controllers\Api\V2\Controllers\AccountController;
|
||||
use LaravelJsonApi\Laravel\Facades\JsonApiRoute;
|
||||
use LaravelJsonApi\Laravel\Http\Controllers\JsonApiController;
|
||||
use LaravelJsonApi\Laravel\Routing\ActionRegistrar;
|
||||
use LaravelJsonApi\Laravel\Routing\Relationships;
|
||||
use LaravelJsonApi\Laravel\Routing\ResourceRegistrar;
|
||||
|
||||
// V2 auto complete controller(s)
|
||||
/*
|
||||
*
|
||||
* ____ ____ ___ .______ ______ __ __ .___________. _______ _______.
|
||||
* \ \ / / |__ \ | _ \ / __ \ | | | | | || ____| / |
|
||||
* \ \/ / ) | | |_) | | | | | | | | | `---| |----`| |__ | (----`
|
||||
* \ / / / | / | | | | | | | | | | | __| \ \
|
||||
* \ / / /_ | |\ \----.| `--' | | `--' | | | | |____.----) |
|
||||
* \__/ |____| | _| `._____| \______/ \______/ |__| |_______|_______/
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* AUTOCOMPLETE ROUTES
|
||||
*/
|
||||
Route::group(
|
||||
[
|
||||
'namespace' => 'FireflyIII\Api\V2\Controllers\Autocomplete',
|
||||
@ -37,7 +50,6 @@ Route::group(
|
||||
'as' => 'api.v2.autocomplete.',
|
||||
],
|
||||
static function (): void {
|
||||
// Auto complete routes
|
||||
Route::get('accounts', ['uses' => 'AccountController@accounts', 'as' => 'accounts']);
|
||||
Route::get('categories', ['uses' => 'CategoryController@categories', 'as' => 'categories']);
|
||||
Route::get('tags', ['uses' => 'TagController@tags', 'as' => 'tags']);
|
||||
@ -45,7 +57,9 @@ Route::group(
|
||||
}
|
||||
);
|
||||
|
||||
// V2 API routes for charts
|
||||
/**
|
||||
* CHART ROUTES
|
||||
*/
|
||||
Route::group(
|
||||
[
|
||||
'namespace' => 'FireflyIII\Api\V2\Controllers\Chart',
|
||||
@ -54,27 +68,13 @@ Route::group(
|
||||
],
|
||||
static function (): void {
|
||||
Route::get('account/dashboard', ['uses' => 'AccountController@dashboard', 'as' => 'account.dashboard']);
|
||||
// Route::get('budget/dashboard', ['uses' => 'BudgetController@dashboard', 'as' => 'budget.dashboard']);
|
||||
// Route::get('category/dashboard', ['uses' => 'CategoryController@dashboard', 'as' => 'category.dashboard']);
|
||||
Route::get('budget/dashboard', ['uses' => 'BudgetController@dashboard', 'as' => 'budget.dashboard']);
|
||||
Route::get('category/dashboard', ['uses' => 'CategoryController@dashboard', 'as' => 'category.dashboard']);
|
||||
Route::get('balance/balance', ['uses' => 'BalanceController@balance', 'as' => 'balance.balance']);
|
||||
}
|
||||
);
|
||||
|
||||
// JsonApiRoute::server('v3')
|
||||
// ->prefix('v3')
|
||||
// ->resources(function (ResourceRegistrar $server) {
|
||||
// $server->resource('accounts', AccountController::class)->readOnly()->relationships(function (Relationships $relations) {
|
||||
// $relations->hasOne('user')->readOnly();
|
||||
// //$relations->hasMany('account_balances')->readOnly();
|
||||
// })
|
||||
// ->actions(function (ActionRegistrar $actions) {
|
||||
// $actions->withId()->get('account-balances', 'readAccountBalances'); // non-eloquent pseudo relation
|
||||
// });
|
||||
// $server->resource('users', JsonApiController::class)->readOnly()->relationships(function (Relationships $relations) {
|
||||
// $relations->hasMany('accounts')->readOnly();
|
||||
// });
|
||||
// $server->resource('account-balances', JsonApiController::class);
|
||||
// });
|
||||
|
||||
|
||||
// V2 API route for Summary boxes
|
||||
// BASIC
|
||||
@ -121,19 +121,19 @@ Route::group(
|
||||
}
|
||||
);
|
||||
|
||||
// V2 API route for accounts.
|
||||
Route::group(
|
||||
[
|
||||
'namespace' => 'FireflyIII\Api\V2\Controllers\Model\Account',
|
||||
'prefix' => 'v2/accounts',
|
||||
'as' => 'api.v2.accounts.',
|
||||
],
|
||||
static function (): void {
|
||||
Route::get('', ['uses' => 'IndexController@index', 'as' => 'index']);
|
||||
Route::get('{account}', ['uses' => 'ShowController@show', 'as' => 'show']);
|
||||
Route::put('{account}', ['uses' => 'UpdateController@update', 'as' => 'update']);
|
||||
}
|
||||
);
|
||||
//// V2 API route for accounts.
|
||||
//Route::group(
|
||||
// [
|
||||
// 'namespace' => 'FireflyIII\Api\V2\Controllers\Model\Account',
|
||||
// 'prefix' => 'v2/accounts',
|
||||
// 'as' => 'api.v2.accounts.',
|
||||
// ],
|
||||
// static function (): void {
|
||||
// Route::get('', ['uses' => 'IndexController@index', 'as' => 'index']);
|
||||
// Route::get('{account}', ['uses' => 'ShowController@show', 'as' => 'show']);
|
||||
// Route::put('{account}', ['uses' => 'UpdateController@update', 'as' => 'update']);
|
||||
// }
|
||||
//);
|
||||
|
||||
// V2 API route for subscriptions.
|
||||
Route::group(
|
||||
@ -247,7 +247,34 @@ Route::group(
|
||||
}
|
||||
);
|
||||
|
||||
// down here is v1
|
||||
/**
|
||||
* V2 JSON API ROUTES
|
||||
*/
|
||||
JsonApiRoute::server('v2')->prefix('v2')
|
||||
->resources(function (ResourceRegistrar $server) {
|
||||
/**
|
||||
* ACCOUNTS
|
||||
*/
|
||||
$server->resource('accounts', AccountController::class)->readOnly()->relationships(function (Relationships $relations) {
|
||||
$relations->hasOne('user')->readOnly();
|
||||
});
|
||||
|
||||
/**
|
||||
* USERS
|
||||
*/
|
||||
$server->resource('users', JsonApiController::class)->readOnly()->relationships(function (Relationships $relations) {
|
||||
$relations->hasMany('accounts')->readOnly();
|
||||
});
|
||||
});
|
||||
|
||||
/*
|
||||
* ____ ____ __ .______ ______ __ __ .___________. _______ _______.
|
||||
* \ \ / / /_ | | _ \ / __ \ | | | | | || ____| / |
|
||||
* \ \/ / | | | |_) | | | | | | | | | `---| |----`| |__ | (----`
|
||||
* \ / | | | / | | | | | | | | | | | __| \ \
|
||||
* \ / | | | |\ \----.| `--' | | `--' | | | | |____.----) |
|
||||
* \__/ |_| | _| `._____| \______/ \______/ |__| |_______|_______/
|
||||
*/
|
||||
|
||||
// Autocomplete controllers
|
||||
Route::group(
|
||||
@ -278,7 +305,7 @@ Route::group(
|
||||
);
|
||||
|
||||
// CHART ROUTES.
|
||||
// Accounts
|
||||
// Chart accounts
|
||||
Route::group(
|
||||
[
|
||||
'namespace' => 'FireflyIII\Api\V1\Controllers\Chart',
|
||||
|
Loading…
Reference in New Issue
Block a user