mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Add attachment helper to relevant classes #2828
This commit is contained in:
parent
aceaf5f891
commit
d489244c00
@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Controllers\Account;
|
namespace FireflyIII\Http\Controllers\Account;
|
||||||
|
|
||||||
|
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
||||||
use FireflyIII\Http\Controllers\Controller;
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
use FireflyIII\Http\Requests\AccountFormRequest;
|
use FireflyIII\Http\Requests\AccountFormRequest;
|
||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
@ -42,6 +43,10 @@ use Log;
|
|||||||
class CreateController extends Controller
|
class CreateController extends Controller
|
||||||
{
|
{
|
||||||
use ModelInformation;
|
use ModelInformation;
|
||||||
|
|
||||||
|
/** @var AttachmentHelperInterface Helper for attachments. */
|
||||||
|
private $attachments;
|
||||||
|
|
||||||
/** @var AccountRepositoryInterface The account repository */
|
/** @var AccountRepositoryInterface The account repository */
|
||||||
private $repository;
|
private $repository;
|
||||||
|
|
||||||
@ -60,7 +65,8 @@ class CreateController extends Controller
|
|||||||
app('view')->share('mainTitleIcon', 'fa-credit-card');
|
app('view')->share('mainTitleIcon', 'fa-credit-card');
|
||||||
app('view')->share('title', (string) trans('firefly.accounts'));
|
app('view')->share('title', (string) trans('firefly.accounts'));
|
||||||
|
|
||||||
$this->repository = app(AccountRepositoryInterface::class);
|
$this->repository = app(AccountRepositoryInterface::class);
|
||||||
|
$this->attachments = app(AttachmentHelperInterface::class);
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
@ -141,6 +147,16 @@ class CreateController extends Controller
|
|||||||
$frontPage[] = $account->id;
|
$frontPage[] = $account->id;
|
||||||
app('preferences')->set('frontPageAccounts', $frontPage);
|
app('preferences')->set('frontPageAccounts', $frontPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// store attachment(s):
|
||||||
|
/** @var array $files */
|
||||||
|
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
|
||||||
|
$this->attachments->saveAttachmentsForModel($account, $files);
|
||||||
|
|
||||||
|
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||||
|
$request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
|
||||||
|
}
|
||||||
|
|
||||||
// redirect to previous URL.
|
// redirect to previous URL.
|
||||||
$redirect = redirect($this->getPreviousUri('accounts.create.uri'));
|
$redirect = redirect($this->getPreviousUri('accounts.create.uri'));
|
||||||
if (1 === (int) $request->get('create_another')) {
|
if (1 === (int) $request->get('create_another')) {
|
||||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Controllers\Account;
|
namespace FireflyIII\Http\Controllers\Account;
|
||||||
|
|
||||||
|
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
||||||
use FireflyIII\Http\Controllers\Controller;
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
use FireflyIII\Http\Requests\AccountFormRequest;
|
use FireflyIII\Http\Requests\AccountFormRequest;
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
@ -48,6 +49,9 @@ class EditController extends Controller
|
|||||||
/** @var AccountRepositoryInterface The account repository */
|
/** @var AccountRepositoryInterface The account repository */
|
||||||
private $repository;
|
private $repository;
|
||||||
|
|
||||||
|
/** @var AttachmentHelperInterface Helper for attachments. */
|
||||||
|
private $attachments;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EditController constructor.
|
* EditController constructor.
|
||||||
*/
|
*/
|
||||||
@ -63,6 +67,7 @@ class EditController extends Controller
|
|||||||
|
|
||||||
$this->repository = app(AccountRepositoryInterface::class);
|
$this->repository = app(AccountRepositoryInterface::class);
|
||||||
$this->currencyRepos = app(CurrencyRepositoryInterface::class);
|
$this->currencyRepos = app(CurrencyRepositoryInterface::class);
|
||||||
|
$this->attachments = app(AttachmentHelperInterface::class);
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
@ -185,6 +190,17 @@ class EditController extends Controller
|
|||||||
$request->session()->flash('success', (string) trans('firefly.updated_account', ['name' => $account->name]));
|
$request->session()->flash('success', (string) trans('firefly.updated_account', ['name' => $account->name]));
|
||||||
app('preferences')->mark();
|
app('preferences')->mark();
|
||||||
|
|
||||||
|
// store new attachments
|
||||||
|
// store attachment(s):
|
||||||
|
/** @var array $files */
|
||||||
|
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
|
||||||
|
$this->attachments->saveAttachmentsForModel($account, $files);
|
||||||
|
|
||||||
|
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||||
|
$request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
|
||||||
|
}
|
||||||
|
|
||||||
|
// redirect
|
||||||
$redirect = redirect($this->getPreviousUri('accounts.edit.uri'));
|
$redirect = redirect($this->getPreviousUri('accounts.edit.uri'));
|
||||||
if (1 === (int) $request->get('return_to_edit')) {
|
if (1 === (int) $request->get('return_to_edit')) {
|
||||||
// set value so edit routine will not overwrite URL:
|
// set value so edit routine will not overwrite URL:
|
||||||
|
@ -24,6 +24,7 @@ declare(strict_types=1);
|
|||||||
namespace FireflyIII\Http\Controllers\Budget;
|
namespace FireflyIII\Http\Controllers\Budget;
|
||||||
|
|
||||||
|
|
||||||
|
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
||||||
use FireflyIII\Http\Controllers\Controller;
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
use FireflyIII\Http\Requests\BudgetFormStoreRequest;
|
use FireflyIII\Http\Requests\BudgetFormStoreRequest;
|
||||||
use FireflyIII\Models\AutoBudget;
|
use FireflyIII\Models\AutoBudget;
|
||||||
@ -41,6 +42,9 @@ class CreateController extends Controller
|
|||||||
/** @var BudgetRepositoryInterface The budget repository */
|
/** @var BudgetRepositoryInterface The budget repository */
|
||||||
private $repository;
|
private $repository;
|
||||||
|
|
||||||
|
/** @var AttachmentHelperInterface Helper for attachments. */
|
||||||
|
private $attachments;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CreateController constructor.
|
* CreateController constructor.
|
||||||
*
|
*
|
||||||
@ -56,6 +60,7 @@ class CreateController extends Controller
|
|||||||
app('view')->share('title', (string) trans('firefly.budgets'));
|
app('view')->share('title', (string) trans('firefly.budgets'));
|
||||||
app('view')->share('mainTitleIcon', 'fa-tasks');
|
app('view')->share('mainTitleIcon', 'fa-tasks');
|
||||||
$this->repository = app(BudgetRepositoryInterface::class);
|
$this->repository = app(BudgetRepositoryInterface::class);
|
||||||
|
$this->attachments = app(AttachmentHelperInterface::class);
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ declare(strict_types=1);
|
|||||||
namespace FireflyIII\Http\Controllers\Budget;
|
namespace FireflyIII\Http\Controllers\Budget;
|
||||||
|
|
||||||
|
|
||||||
|
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
||||||
use FireflyIII\Http\Controllers\Controller;
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
use FireflyIII\Http\Requests\BudgetFormUpdateRequest;
|
use FireflyIII\Http\Requests\BudgetFormUpdateRequest;
|
||||||
use FireflyIII\Models\AutoBudget;
|
use FireflyIII\Models\AutoBudget;
|
||||||
@ -43,6 +44,9 @@ class EditController extends Controller
|
|||||||
/** @var BudgetRepositoryInterface The budget repository */
|
/** @var BudgetRepositoryInterface The budget repository */
|
||||||
private $repository;
|
private $repository;
|
||||||
|
|
||||||
|
/** @var AttachmentHelperInterface Helper for attachments. */
|
||||||
|
private $attachments;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EditController constructor.
|
* EditController constructor.
|
||||||
*
|
*
|
||||||
@ -57,6 +61,7 @@ class EditController extends Controller
|
|||||||
app('view')->share('title', (string) trans('firefly.budgets'));
|
app('view')->share('title', (string) trans('firefly.budgets'));
|
||||||
app('view')->share('mainTitleIcon', 'fa-tasks');
|
app('view')->share('mainTitleIcon', 'fa-tasks');
|
||||||
$this->repository = app(BudgetRepositoryInterface::class);
|
$this->repository = app(BudgetRepositoryInterface::class);
|
||||||
|
$this->attachments = app(AttachmentHelperInterface::class);
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ declare(strict_types=1);
|
|||||||
namespace FireflyIII\Http\Controllers\Category;
|
namespace FireflyIII\Http\Controllers\Category;
|
||||||
|
|
||||||
|
|
||||||
|
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
||||||
use FireflyIII\Http\Controllers\Controller;
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
use FireflyIII\Http\Requests\CategoryFormRequest;
|
use FireflyIII\Http\Requests\CategoryFormRequest;
|
||||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||||
@ -41,6 +42,9 @@ class CreateController extends Controller
|
|||||||
/** @var CategoryRepositoryInterface The category repository */
|
/** @var CategoryRepositoryInterface The category repository */
|
||||||
private $repository;
|
private $repository;
|
||||||
|
|
||||||
|
/** @var AttachmentHelperInterface Helper for attachments. */
|
||||||
|
private $attachments;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CategoryController constructor.
|
* CategoryController constructor.
|
||||||
*
|
*
|
||||||
@ -55,6 +59,7 @@ class CreateController extends Controller
|
|||||||
app('view')->share('title', (string) trans('firefly.categories'));
|
app('view')->share('title', (string) trans('firefly.categories'));
|
||||||
app('view')->share('mainTitleIcon', 'fa-bar-chart');
|
app('view')->share('mainTitleIcon', 'fa-bar-chart');
|
||||||
$this->repository = app(CategoryRepositoryInterface::class);
|
$this->repository = app(CategoryRepositoryInterface::class);
|
||||||
|
$this->attachments = app(AttachmentHelperInterface::class);
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ declare(strict_types=1);
|
|||||||
namespace FireflyIII\Http\Controllers\Category;
|
namespace FireflyIII\Http\Controllers\Category;
|
||||||
|
|
||||||
|
|
||||||
|
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
||||||
use FireflyIII\Http\Controllers\Controller;
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
use FireflyIII\Http\Requests\CategoryFormRequest;
|
use FireflyIII\Http\Requests\CategoryFormRequest;
|
||||||
use FireflyIII\Models\Category;
|
use FireflyIII\Models\Category;
|
||||||
@ -43,6 +44,9 @@ class EditController extends Controller
|
|||||||
/** @var CategoryRepositoryInterface The category repository */
|
/** @var CategoryRepositoryInterface The category repository */
|
||||||
private $repository;
|
private $repository;
|
||||||
|
|
||||||
|
/** @var AttachmentHelperInterface Helper for attachments. */
|
||||||
|
private $attachments;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CategoryController constructor.
|
* CategoryController constructor.
|
||||||
*
|
*
|
||||||
@ -57,6 +61,7 @@ class EditController extends Controller
|
|||||||
app('view')->share('title', (string) trans('firefly.categories'));
|
app('view')->share('title', (string) trans('firefly.categories'));
|
||||||
app('view')->share('mainTitleIcon', 'fa-bar-chart');
|
app('view')->share('mainTitleIcon', 'fa-bar-chart');
|
||||||
$this->repository = app(CategoryRepositoryInterface::class);
|
$this->repository = app(CategoryRepositoryInterface::class);
|
||||||
|
$this->attachments = app(AttachmentHelperInterface::class);
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||||||
namespace FireflyIII\Http\Controllers;
|
namespace FireflyIII\Http\Controllers;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
||||||
use FireflyIII\Http\Requests\PiggyBankFormRequest;
|
use FireflyIII\Http\Requests\PiggyBankFormRequest;
|
||||||
use FireflyIII\Models\PiggyBank;
|
use FireflyIII\Models\PiggyBank;
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
@ -55,6 +56,9 @@ class PiggyBankController extends Controller
|
|||||||
/** @var PiggyBankRepositoryInterface Piggy bank repository. */
|
/** @var PiggyBankRepositoryInterface Piggy bank repository. */
|
||||||
private $piggyRepos;
|
private $piggyRepos;
|
||||||
|
|
||||||
|
/** @var AttachmentHelperInterface Helper for attachments. */
|
||||||
|
private $attachments;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PiggyBankController constructor.
|
* PiggyBankController constructor.
|
||||||
*
|
*
|
||||||
@ -69,6 +73,7 @@ class PiggyBankController extends Controller
|
|||||||
app('view')->share('title', (string) trans('firefly.piggyBanks'));
|
app('view')->share('title', (string) trans('firefly.piggyBanks'));
|
||||||
app('view')->share('mainTitleIcon', 'fa-sort-amount-asc');
|
app('view')->share('mainTitleIcon', 'fa-sort-amount-asc');
|
||||||
|
|
||||||
|
$this->attachments = app(AttachmentHelperInterface::class);
|
||||||
$this->piggyRepos = app(PiggyBankRepositoryInterface::class);
|
$this->piggyRepos = app(PiggyBankRepositoryInterface::class);
|
||||||
$this->currencyRepos = app(CurrencyRepositoryInterface::class);
|
$this->currencyRepos = app(CurrencyRepositoryInterface::class);
|
||||||
$this->accountRepos = app(AccountRepositoryInterface::class);
|
$this->accountRepos = app(AccountRepositoryInterface::class);
|
||||||
|
@ -24,6 +24,7 @@ declare(strict_types=1);
|
|||||||
namespace FireflyIII\Http\Controllers;
|
namespace FireflyIII\Http\Controllers;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
||||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||||
use FireflyIII\Http\Requests\TagFormRequest;
|
use FireflyIII\Http\Requests\TagFormRequest;
|
||||||
use FireflyIII\Models\Tag;
|
use FireflyIII\Models\Tag;
|
||||||
@ -45,6 +46,9 @@ class TagController extends Controller
|
|||||||
/** @var TagRepositoryInterface The tag repository. */
|
/** @var TagRepositoryInterface The tag repository. */
|
||||||
protected $repository;
|
protected $repository;
|
||||||
|
|
||||||
|
/** @var AttachmentHelperInterface Helper for attachments. */
|
||||||
|
private $attachments;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TagController constructor.
|
* TagController constructor.
|
||||||
*/
|
*/
|
||||||
@ -55,10 +59,12 @@ class TagController extends Controller
|
|||||||
|
|
||||||
$this->middleware(
|
$this->middleware(
|
||||||
function ($request, $next) {
|
function ($request, $next) {
|
||||||
$this->repository = app(TagRepositoryInterface::class);
|
|
||||||
app('view')->share('title', (string) trans('firefly.tags'));
|
app('view')->share('title', (string) trans('firefly.tags'));
|
||||||
app('view')->share('mainTitleIcon', 'fa-tags');
|
app('view')->share('mainTitleIcon', 'fa-tags');
|
||||||
|
|
||||||
|
$this->attachments = app(AttachmentHelperInterface::class);
|
||||||
|
$this->repository = app(TagRepositoryInterface::class);
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user