mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-28 01:41:14 -06:00
Move CRUD method count() to account repository
This commit is contained in:
parent
3f40751a1a
commit
1d2d3523d6
@ -52,18 +52,6 @@ class AccountCrud implements AccountCrudInterface
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $types
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count(array $types):int
|
||||
{
|
||||
$count = $this->user->accounts()->accountTypeIn($types)->count();
|
||||
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
* @param Account $moveTo
|
||||
|
@ -24,13 +24,6 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
interface AccountCrudInterface
|
||||
{
|
||||
/**
|
||||
* @param array $types
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count(array $types):int;
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
* @param Account $moveTo
|
||||
|
@ -123,7 +123,7 @@ class HomeController extends Controller
|
||||
{
|
||||
|
||||
$types = config('firefly.accountTypesByIdentifier.asset');
|
||||
$count = $crud->count($types);
|
||||
$count = $repository->count($types);
|
||||
|
||||
if ($count == 0) {
|
||||
return redirect(route('new-user.index'));
|
||||
|
@ -15,6 +15,7 @@ namespace FireflyIII\Http\Controllers;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Crud\Account\AccountCrudInterface;
|
||||
use FireflyIII\Http\Requests\NewUserFormRequest;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use Preferences;
|
||||
use Session;
|
||||
use View;
|
||||
@ -36,11 +37,11 @@ class NewUserController extends Controller
|
||||
|
||||
|
||||
/**
|
||||
* @param AccountCrudInterface $crud
|
||||
* @param AccountRepositoryInterface $repository
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View
|
||||
*/
|
||||
public function index(AccountCrudInterface $crud)
|
||||
public function index(AccountRepositoryInterface $repository)
|
||||
{
|
||||
|
||||
View::share('title', trans('firefly.welcome'));
|
||||
@ -48,7 +49,7 @@ class NewUserController extends Controller
|
||||
|
||||
|
||||
$types = config('firefly.accountTypesByIdentifier.asset');
|
||||
$count = $crud->count($types);
|
||||
$count = $repository->count($types);
|
||||
|
||||
if ($count > 0) {
|
||||
return redirect(route('index'));
|
||||
|
@ -50,6 +50,20 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Moved here from account CRUD
|
||||
*
|
||||
* @param array $types
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count(array $types):int
|
||||
{
|
||||
$count = $this->user->accounts()->accountTypeIn($types)->count();
|
||||
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will call AccountRepositoryInterface::journalsInPeriod and get all withdrawaks made from the given $accounts,
|
||||
* as well as the transfers that move away from those $accounts. This is a slightly sharper selection
|
||||
|
@ -26,6 +26,14 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
interface AccountRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* Moved here from account CRUD.
|
||||
*
|
||||
* @param array $types
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count(array $types): int;
|
||||
|
||||
/**
|
||||
* This method will call AccountRepositoryInterface::journalsInPeriod and get all withdrawaks made from the given $accounts,
|
||||
|
Loading…
Reference in New Issue
Block a user