mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-11-21 16:38:36 -06:00
New API stuff
This commit is contained in:
parent
7e37d10016
commit
76a41fec50
@ -27,6 +27,7 @@ use FireflyIII\Models\Account;
|
||||
use FireflyIII\Support\JsonApi\Concerns\UsergroupAware;
|
||||
use FireflyIII\Support\JsonApi\Enrichments\AccountEnrichment;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use LaravelJsonApi\Contracts\Store\CreatesResources;
|
||||
use LaravelJsonApi\Contracts\Store\QueriesAll;
|
||||
use LaravelJsonApi\NonEloquent\AbstractRepository;
|
||||
use LaravelJsonApi\NonEloquent\Capabilities\CrudRelations;
|
||||
@ -43,12 +44,14 @@ use LaravelJsonApi\NonEloquent\Concerns\HasRelationsCapability;
|
||||
* This is necessary because the user can't just query all accounts (it would return other user's data)
|
||||
* and because we also need to collect all kinds of metadata, like the currency and user info.
|
||||
*/
|
||||
class AccountRepository extends AbstractRepository implements QueriesAll
|
||||
class AccountRepository extends AbstractRepository implements QueriesAll, CreatesResources
|
||||
{
|
||||
use HasCrudCapability;
|
||||
use HasRelationsCapability;
|
||||
use UsergroupAware;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* SiteRepository constructor.
|
||||
*/
|
||||
|
24
app/JsonApi/V2/Accounts/AccountRequest.php
Normal file
24
app/JsonApi/V2/Accounts/AccountRequest.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace FireflyIII\JsonApi\V2\Accounts;
|
||||
|
||||
use Illuminate\Validation\Rule;
|
||||
use LaravelJsonApi\Laravel\Http\Requests\ResourceRequest;
|
||||
use LaravelJsonApi\Validation\Rule as JsonApiRule;
|
||||
|
||||
class AccountRequest extends ResourceRequest
|
||||
{
|
||||
|
||||
/**
|
||||
* Get the validation rules for the resource.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
// @TODO
|
||||
];
|
||||
}
|
||||
|
||||
}
|
@ -39,4 +39,8 @@ class CrudAccount extends CrudResource
|
||||
|
||||
return $enrichment->enrichSingle($account);
|
||||
}
|
||||
|
||||
public function create(array $validatedData): Account {
|
||||
die('here we are');
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ class AccountPolicy
|
||||
*/
|
||||
public function view(User $user, Account $account): bool
|
||||
{
|
||||
die('OK');
|
||||
return true;
|
||||
|
||||
return auth()->check() && $user->id === $account->user_id;
|
||||
@ -45,6 +46,7 @@ class AccountPolicy
|
||||
*/
|
||||
public function viewAny(): bool
|
||||
{
|
||||
die('OK');
|
||||
return true;
|
||||
|
||||
return auth()->check();
|
||||
|
@ -243,7 +243,7 @@ Route::group(
|
||||
JsonApiRoute::server('v2')->prefix('v2')
|
||||
->resources(function (ResourceRegistrar $server): void {
|
||||
// ACCOUNTS
|
||||
$server->resource('accounts', AccountController::class)->readOnly()->relationships(function (Relationships $relations): void {
|
||||
$server->resource('accounts', AccountController::class)->relationships(function (Relationships $relations): void {
|
||||
$relations->hasOne('user')->readOnly();
|
||||
});
|
||||
// $server->resource('accounts', AccountController::class)->readOnly();
|
||||
|
Loading…
Reference in New Issue
Block a user