diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index aa2805e9ae..dc634190ca 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -21,7 +21,6 @@ use FireflyIII\Console\Commands\ScanAttachments; use FireflyIII\Console\Commands\UpgradeDatabase; use FireflyIII\Console\Commands\UpgradeFireflyInstructions; use FireflyIII\Console\Commands\VerifyDatabase; -use Illuminate\Console\Scheduling\Schedule; use Illuminate\Foundation\Console\Kernel as ConsoleKernel; /** diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 1ee5cc1c74..c61dac5629 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -19,9 +19,9 @@ use Illuminate\Auth\Access\AuthorizationException; use Illuminate\Auth\AuthenticationException; use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; -use Request; use Illuminate\Session\TokenMismatchException; use Illuminate\Validation\ValidationException as ValException; +use Request; use Symfony\Component\HttpKernel\Exception\HttpException; /** diff --git a/app/Helpers/Collector/JournalCollector.php b/app/Helpers/Collector/JournalCollector.php index f4a4713546..7ea500b656 100644 --- a/app/Helpers/Collector/JournalCollector.php +++ b/app/Helpers/Collector/JournalCollector.php @@ -672,7 +672,9 @@ class JournalCollector implements JournalCollectorInterface // join some extra tables: $this->joinedCategory = true; $this->query->leftJoin('category_transaction_journal', 'category_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id'); - $this->query->leftJoin('categories as transaction_journal_categories', 'transaction_journal_categories.id', '=', 'category_transaction_journal.category_id'); + $this->query->leftJoin( + 'categories as transaction_journal_categories', 'transaction_journal_categories.id', '=', 'category_transaction_journal.category_id' + ); $this->query->leftJoin('category_transaction', 'category_transaction.transaction_id', '=', 'transactions.id'); $this->query->leftJoin('categories as transaction_categories', 'transaction_categories.id', '=', 'category_transaction.category_id'); diff --git a/app/Http/Controllers/Admin/ConfigurationController.php b/app/Http/Controllers/Admin/ConfigurationController.php index fb71cb3fc0..909d33ae62 100644 --- a/app/Http/Controllers/Admin/ConfigurationController.php +++ b/app/Http/Controllers/Admin/ConfigurationController.php @@ -58,9 +58,9 @@ class ConfigurationController extends Controller // all available configuration and their default value in case // they don't exist yet. - $singleUserMode = FireflyConfig::get('single_user_mode', config('firefly.configuration.single_user_mode'))->data; - $isDemoSite = FireflyConfig::get('is_demo_site', config('firefly.configuration.is_demo_site'))->data; - $siteOwner = env('SITE_OWNER'); + $singleUserMode = FireflyConfig::get('single_user_mode', config('firefly.configuration.single_user_mode'))->data; + $isDemoSite = FireflyConfig::get('is_demo_site', config('firefly.configuration.is_demo_site'))->data; + $siteOwner = env('SITE_OWNER'); return view( 'admin.configuration.index', diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 30d8c34481..c6389159b8 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -154,6 +154,7 @@ class LoginController extends Controller $code = strlen(strval($foundUser->blocked_code)) > 0 ? $foundUser->blocked_code : 'general_blocked'; $errorMessage = strval(trans('firefly.' . $code . '_error', ['email' => $email])); } + return $errorMessage; } } diff --git a/app/Http/Controllers/Chart/BillController.php b/app/Http/Controllers/Chart/BillController.php index 881eaeb002..14588e0720 100644 --- a/app/Http/Controllers/Chart/BillController.php +++ b/app/Http/Controllers/Chart/BillController.php @@ -91,8 +91,8 @@ class BillController extends Controller return Response::json($cache->get()); } - $results = $collector->setAllAssetAccounts()->setBills(new Collection([$bill]))->getJournals(); - $results = $results->sortBy( + $results = $collector->setAllAssetAccounts()->setBills(new Collection([$bill]))->getJournals(); + $results = $results->sortBy( function (Transaction $transaction) { return $transaction->date->format('U'); } diff --git a/app/Http/Controllers/Transaction/SingleController.php b/app/Http/Controllers/Transaction/SingleController.php index 1956de22ae..b1133686f3 100644 --- a/app/Http/Controllers/Transaction/SingleController.php +++ b/app/Http/Controllers/Transaction/SingleController.php @@ -315,7 +315,7 @@ class SingleController extends Controller $data = $request->getJournalData(); $journal = $repository->update($journal, $data); - $files = $request->hasFile('attachments') ? $request->file('attachments') : null; + $files = $request->hasFile('attachments') ? $request->file('attachments') : null; $this->attachments->saveAttachmentsForModel($journal, $files); // flash errors diff --git a/app/Http/Requests/ConfigurationRequest.php b/app/Http/Requests/ConfigurationRequest.php index f8e3c7c68b..d6bd5d7ca2 100644 --- a/app/Http/Requests/ConfigurationRequest.php +++ b/app/Http/Requests/ConfigurationRequest.php @@ -36,8 +36,8 @@ class ConfigurationRequest extends Request public function getConfigurationData(): array { return [ - 'single_user_mode' => intval($this->get('single_user_mode')) === 1, - 'is_demo_site' => intval($this->get('is_demo_site')) === 1, + 'single_user_mode' => intval($this->get('single_user_mode')) === 1, + 'is_demo_site' => intval($this->get('is_demo_site')) === 1, ]; } @@ -47,8 +47,8 @@ class ConfigurationRequest extends Request public function rules() { $rules = [ - 'single_user_mode' => 'between:0,1|numeric', - 'is_demo_site' => 'between:0,1|numeric', + 'single_user_mode' => 'between:0,1|numeric', + 'is_demo_site' => 'between:0,1|numeric', ]; return $rules; diff --git a/app/Http/breadcrumbs.php b/app/Http/breadcrumbs.php index e77a25f372..b7a64a5c07 100644 --- a/app/Http/breadcrumbs.php +++ b/app/Http/breadcrumbs.php @@ -280,10 +280,10 @@ Breadcrumbs::register( $title = trans( 'firefly.budget_in_period_breadcrumb', [ - 'name' => $budget->name, - 'start' => $budgetLimit->start_date->formatLocalized(strval(trans('config.month_and_day'))), - 'end' => $budgetLimit->end_date->formatLocalized(strval(trans('config.month_and_day'))), - ] + 'name' => $budget->name, + 'start' => $budgetLimit->start_date->formatLocalized(strval(trans('config.month_and_day'))), + 'end' => $budgetLimit->end_date->formatLocalized(strval(trans('config.month_and_day'))), + ] ); $breadcrumbs->push( diff --git a/app/Models/AccountMeta.php b/app/Models/AccountMeta.php index 797058c122..48953f09d5 100644 --- a/app/Models/AccountMeta.php +++ b/app/Models/AccountMeta.php @@ -35,7 +35,7 @@ class AccountMeta extends Model 'updated_at' => 'date', ]; /** @var array */ - protected $dates = ['created_at', 'updated_at']; + protected $dates = ['created_at', 'updated_at']; protected $fillable = ['account_id', 'name', 'data']; protected $table = 'account_meta'; diff --git a/app/Models/Attachment.php b/app/Models/Attachment.php index 84dfbfc106..36599f3d6b 100644 --- a/app/Models/Attachment.php +++ b/app/Models/Attachment.php @@ -43,7 +43,7 @@ class Attachment extends Model ]; /** @var array */ protected $dates = ['created_at', 'updated_at', 'deleted_at']; - /** @var array */ + /** @var array */ protected $fillable = ['attachable_id', 'attachable_type', 'user_id', 'md5', 'filename', 'mime', 'title', 'notes', 'description', 'size', 'uploaded']; /** diff --git a/app/Models/AvailableBudget.php b/app/Models/AvailableBudget.php index c96893fbb9..d51d8b0418 100644 --- a/app/Models/AvailableBudget.php +++ b/app/Models/AvailableBudget.php @@ -26,11 +26,6 @@ use Illuminate\Database\Eloquent\SoftDeletes; class AvailableBudget extends Model { use SoftDeletes; - /** @var array */ - protected $fillable = ['user_id', 'transaction_currency_id', 'amount', 'start_date', 'end_date']; - - /** @var array */ - protected $dates = ['created_at', 'updated_at', 'deleted_at']; /** * The attributes that should be casted to native types. * @@ -42,8 +37,12 @@ class AvailableBudget extends Model 'updated_at' => 'date', 'deleted_at' => 'date', 'start_date' => 'date', - 'end_date' => 'date', + 'end_date' => 'date', ]; + /** @var array */ + protected $dates = ['created_at', 'updated_at', 'deleted_at']; + /** @var array */ + protected $fillable = ['user_id', 'transaction_currency_id', 'amount', 'start_date', 'end_date']; /** * @return \Illuminate\Database\Eloquent\Relations\BelongsTo diff --git a/app/Models/Budget.php b/app/Models/Budget.php index 4d5c2a61c6..d62e195352 100644 --- a/app/Models/Budget.php +++ b/app/Models/Budget.php @@ -30,9 +30,6 @@ class Budget extends Model use SoftDeletes, ValidatingTrait; - /** @var array */ - protected $dates = ['created_at', 'updated_at', 'deleted_at']; - /** * The attributes that should be casted to native types. * @@ -46,7 +43,8 @@ class Budget extends Model 'active' => 'boolean', 'encrypted' => 'boolean', ]; - + /** @var array */ + protected $dates = ['created_at', 'updated_at', 'deleted_at']; protected $fillable = ['user_id', 'name', 'active']; protected $hidden = ['encrypted']; protected $rules = ['name' => 'required|between:1,200',]; diff --git a/app/Models/Category.php b/app/Models/Category.php index c0db1259b8..e8e665bff2 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -41,14 +41,14 @@ class Category extends Model 'deleted_at' => 'date', 'encrypted' => 'boolean', ]; - /** @var array */ - protected $fillable = ['user_id', 'name']; - /** @var array */ - protected $hidden = ['encrypted']; - /** @var array */ - protected $rules = ['name' => 'required|between:1,200',]; /** @var array */ protected $dates = ['created_at', 'updated_at', 'deleted_at']; + /** @var array */ + protected $fillable = ['user_id', 'name']; + /** @var array */ + protected $hidden = ['encrypted']; + /** @var array */ + protected $rules = ['name' => 'required|between:1,200',]; /** * @param array $fields diff --git a/app/Models/LimitRepetition.php b/app/Models/LimitRepetition.php index a1e8afe2b1..d4f5b5f3dc 100644 --- a/app/Models/LimitRepetition.php +++ b/app/Models/LimitRepetition.php @@ -33,7 +33,7 @@ class LimitRepetition extends Model * @var array */ protected $casts - = [ + = [ 'created_at' => 'date', 'updated_at' => 'date', 'startdate' => 'date', diff --git a/app/Models/Note.php b/app/Models/Note.php index 58600a8073..55ee792ce9 100644 --- a/app/Models/Note.php +++ b/app/Models/Note.php @@ -29,7 +29,7 @@ class Note extends Model * @var array */ protected $casts - = [ + = [ 'created_at' => 'date', 'updated_at' => 'date', 'deleted_at' => 'date', diff --git a/app/Models/PiggyBankEvent.php b/app/Models/PiggyBankEvent.php index be731402ab..a84383100d 100644 --- a/app/Models/PiggyBankEvent.php +++ b/app/Models/PiggyBankEvent.php @@ -29,7 +29,7 @@ class PiggyBankEvent extends Model * @var array */ protected $casts - = [ + = [ 'created_at' => 'date', 'updated_at' => 'date', 'date' => 'date', diff --git a/app/Models/PiggyBankRepetition.php b/app/Models/PiggyBankRepetition.php index 8b048879df..1d9dca1eb0 100644 --- a/app/Models/PiggyBankRepetition.php +++ b/app/Models/PiggyBankRepetition.php @@ -31,7 +31,7 @@ class PiggyBankRepetition extends Model * @var array */ protected $casts - = [ + = [ 'created_at' => 'date', 'updated_at' => 'date', 'deleted_at' => 'date', diff --git a/app/Models/Preference.php b/app/Models/Preference.php index 5ec7b943ad..f5a81dd909 100644 --- a/app/Models/Preference.php +++ b/app/Models/Preference.php @@ -33,7 +33,7 @@ class Preference extends Model * @var array */ protected $casts - = [ + = [ 'created_at' => 'date', 'updated_at' => 'date', ]; diff --git a/app/Models/RuleGroup.php b/app/Models/RuleGroup.php index b4be42a160..98cbdc0889 100644 --- a/app/Models/RuleGroup.php +++ b/app/Models/RuleGroup.php @@ -32,11 +32,11 @@ class RuleGroup extends Model */ protected $casts = [ - 'created_at' => 'date', - 'updated_at' => 'date', - 'deleted_at' => 'date', - 'active' => 'boolean', - 'order' => 'int', + 'created_at' => 'date', + 'updated_at' => 'date', + 'deleted_at' => 'date', + 'active' => 'boolean', + 'order' => 'int', ]; /** @var array */ protected $dates = ['created_at', 'updated_at', 'deleted_at']; diff --git a/app/Models/TransactionJournalMeta.php b/app/Models/TransactionJournalMeta.php index 6d54430a47..a3f6ec92ba 100644 --- a/app/Models/TransactionJournalMeta.php +++ b/app/Models/TransactionJournalMeta.php @@ -32,7 +32,7 @@ class TransactionJournalMeta extends Model * @var array */ protected $casts - = [ + = [ 'created_at' => 'date', 'updated_at' => 'date', 'deleted_at' => 'date', diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index 19d79a9fd6..215fc5978e 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -37,13 +37,13 @@ class EventServiceProvider extends ServiceProvider protected $listen = [ // new event handlers: - 'FireflyIII\Events\RegisteredUser' => // is a User related event. + 'FireflyIII\Events\RegisteredUser' => // is a User related event. [ 'FireflyIII\Handlers\Events\UserEventHandler@sendRegistrationMail', 'FireflyIII\Handlers\Events\UserEventHandler@attachUserRole', ], - 'FireflyIII\Events\RequestedNewPassword' => [ // is a User related event. - 'FireflyIII\Handlers\Events\UserEventHandler@sendNewPassword', + 'FireflyIII\Events\RequestedNewPassword' => [ // is a User related event. + 'FireflyIII\Handlers\Events\UserEventHandler@sendNewPassword', ], 'FireflyIII\Events\StoredTransactionJournal' => // is a Transaction Journal related event. [ diff --git a/app/Repositories/Attachment/AttachmentRepositoryInterface.php b/app/Repositories/Attachment/AttachmentRepositoryInterface.php index 733e3bd59f..9e12092c70 100644 --- a/app/Repositories/Attachment/AttachmentRepositoryInterface.php +++ b/app/Repositories/Attachment/AttachmentRepositoryInterface.php @@ -32,11 +32,6 @@ interface AttachmentRepositoryInterface */ public function destroy(Attachment $attachment): bool; - /** - * @return Collection - */ - public function get(): Collection; - /** * @param Attachment $attachment * @@ -45,11 +40,9 @@ interface AttachmentRepositoryInterface public function exists(Attachment $attachment): bool; /** - * @param Attachment $attachment - * - * @return string + * @return Collection */ - public function getContent(Attachment $attachment): string; + public function get(): Collection; /** * @param Carbon $start @@ -59,6 +52,13 @@ interface AttachmentRepositoryInterface */ public function getBetween(Carbon $start, Carbon $end): Collection; + /** + * @param Attachment $attachment + * + * @return string + */ + public function getContent(Attachment $attachment): string; + /** * @param Attachment $attachment * @param array $attachmentData diff --git a/app/Repositories/Budget/BudgetRepositoryInterface.php b/app/Repositories/Budget/BudgetRepositoryInterface.php index 947721ea5e..6ccb7da0bf 100644 --- a/app/Repositories/Budget/BudgetRepositoryInterface.php +++ b/app/Repositories/Budget/BudgetRepositoryInterface.php @@ -83,6 +83,14 @@ interface BudgetRepositoryInterface */ public function getActiveBudgets(): Collection; + /** + * @param Carbon $start + * @param Carbon $end + * + * @return Collection + */ + public function getAllBudgetLimits(Carbon $start, Carbon $end): Collection; + /** * @param TransactionCurrency $currency * @param Carbon $start @@ -92,14 +100,6 @@ interface BudgetRepositoryInterface */ public function getAvailableBudget(TransactionCurrency $currency, Carbon $start, Carbon $end): string; - /** - * @param Carbon $start - * @param Carbon $end - * - * @return Collection - */ - public function getAllBudgetLimits(Carbon $start, Carbon $end): Collection; - /** * @param Budget $budget * @param Carbon $start diff --git a/app/Repositories/Category/CategoryRepository.php b/app/Repositories/Category/CategoryRepository.php index 451d995d59..9b881df691 100644 --- a/app/Repositories/Category/CategoryRepository.php +++ b/app/Repositories/Category/CategoryRepository.php @@ -146,7 +146,6 @@ class CategoryRepository implements CategoryRepositoryInterface ->orderBy('transaction_journals.date', 'ASC')->first(['transaction_journals.date']); - // both exist, the one that is earliest "wins". if (!is_null($firstTransaction) && !is_null($first) && Carbon::parse($firstTransaction->date)->lt($first)) { $first = $firstTransaction->date; diff --git a/app/Repositories/ExportJob/ExportJobRepositoryInterface.php b/app/Repositories/ExportJob/ExportJobRepositoryInterface.php index f9e7a4402d..dbb4a04418 100644 --- a/app/Repositories/ExportJob/ExportJobRepositoryInterface.php +++ b/app/Repositories/ExportJob/ExportJobRepositoryInterface.php @@ -22,6 +22,14 @@ use FireflyIII\Models\ExportJob; */ interface ExportJobRepositoryInterface { + /** + * @param ExportJob $job + * @param string $status + * + * @return bool + */ + public function changeStatus(ExportJob $job, string $status): bool; + /** * @return bool */ @@ -32,14 +40,6 @@ interface ExportJobRepositoryInterface */ public function create(): ExportJob; - /** - * @param ExportJob $job - * @param string $status - * - * @return bool - */ - public function changeStatus(ExportJob $job, string $status): bool; - /** * @param ExportJob $job * diff --git a/app/Repositories/User/UserRepository.php b/app/Repositories/User/UserRepository.php index c0e8cac992..ec2a6c7442 100644 --- a/app/Repositories/User/UserRepository.php +++ b/app/Repositories/User/UserRepository.php @@ -14,7 +14,6 @@ declare(strict_types = 1); namespace FireflyIII\Repositories\User; -use FireflyConfig; use FireflyIII\Models\BudgetLimit; use FireflyIII\Models\Role; use FireflyIII\User; @@ -53,6 +52,20 @@ class UserRepository implements UserRepositoryInterface return true; } + /** + * @param User $user + * @param string $password + * + * @return bool + */ + public function changePassword(User $user, string $password): bool + { + $user->password = bcrypt($password); + $user->save(); + + return true; + } + /** * @return int */ @@ -134,17 +147,4 @@ class UserRepository implements UserRepositoryInterface return $return; } - - /** - * @param User $user - * @param string $password - * - * @return bool - */ - public function changePassword(User $user, string $password): bool - { - $user->password = bcrypt($password); - $user->save(); - return true; - } } diff --git a/app/Rules/TransactionMatcher.php b/app/Rules/TransactionMatcher.php index 6ef720774a..acac7c8521 100644 --- a/app/Rules/TransactionMatcher.php +++ b/app/Rules/TransactionMatcher.php @@ -13,7 +13,6 @@ declare(strict_types = 1); namespace FireflyIII\Rules; -use FireflyIII\Helpers\Collector\JournalCollector; use FireflyIII\Helpers\Collector\JournalCollectorInterface; use FireflyIII\Models\Transaction; use FireflyIII\Models\TransactionType; diff --git a/app/Support/Navigation.php b/app/Support/Navigation.php index 6a6e360e78..189b48437e 100644 --- a/app/Support/Navigation.php +++ b/app/Support/Navigation.php @@ -243,28 +243,6 @@ class Navigation throw new FireflyException(sprintf('No date formats for frequency "%s"!', $repeatFrequency)); } - /** - * If the date difference between start and end is less than a month, method returns "endOfDay". If the difference is less than a year, - * method returns "endOfMonth". If the date difference is larger, method returns "endOfYear". - * - * @param \Carbon\Carbon $start - * @param \Carbon\Carbon $end - * - * @return string - */ - public function preferredEndOfPeriod(Carbon $start, Carbon $end): string - { - $format = 'endOfDay'; - if ($start->diffInMonths($end) > 1) { - $format = 'endOfMonth'; - } - - if ($start->diffInMonths($end) > 12) { - $format = 'endOfYear'; - } - return $format; - } - /** * If the date difference between start and end is less than a month, method returns "Y-m-d". If the difference is less than a year, * method returns "Y-m". If the date difference is larger, method returns "Y". @@ -284,6 +262,7 @@ class Navigation if ($start->diffInMonths($end) > 12) { $format = 'Y'; } + return $format; } @@ -311,6 +290,29 @@ class Navigation } + /** + * If the date difference between start and end is less than a month, method returns "endOfDay". If the difference is less than a year, + * method returns "endOfMonth". If the date difference is larger, method returns "endOfYear". + * + * @param \Carbon\Carbon $start + * @param \Carbon\Carbon $end + * + * @return string + */ + public function preferredEndOfPeriod(Carbon $start, Carbon $end): string + { + $format = 'endOfDay'; + if ($start->diffInMonths($end) > 1) { + $format = 'endOfMonth'; + } + + if ($start->diffInMonths($end) > 12) { + $format = 'endOfYear'; + } + + return $format; + } + /** * If the date difference between start and end is less than a month, method returns "1D". If the difference is less than a year, * method returns "1M". If the date difference is larger, method returns "1Y". diff --git a/app/Support/Twig/Journal.php b/app/Support/Twig/Journal.php index 3c52ad161e..757264a240 100644 --- a/app/Support/Twig/Journal.php +++ b/app/Support/Twig/Journal.php @@ -14,10 +14,8 @@ declare(strict_types = 1); namespace FireflyIII\Support\Twig; -use Amount; use FireflyIII\Models\Account; use FireflyIII\Models\AccountType; -use FireflyIII\Models\Budget as ModelBudget; use FireflyIII\Models\Category; use FireflyIII\Models\TransactionJournal; use FireflyIII\Support\CacheProperties; diff --git a/app/User.php b/app/User.php index 763d33d92c..06a150ef49 100644 --- a/app/User.php +++ b/app/User.php @@ -51,15 +51,6 @@ class User extends Authenticatable */ protected $table = 'users'; - - /** - * @return HasMany - */ - public function availableBudgets(): HasMany - { - return $this->hasMany('FireflyIII\Models\AvailableBudget'); - } - /** * @return HasMany */ @@ -96,6 +87,14 @@ class User extends Authenticatable return $this->hasMany('FireflyIII\Models\Attachment'); } + /** + * @return HasMany + */ + public function availableBudgets(): HasMany + { + return $this->hasMany('FireflyIII\Models\AvailableBudget'); + } + /** * @return HasMany */ diff --git a/storage/database/databasecopy.sqlite b/storage/database/databasecopy.sqlite index ed2cee66a9..e1d1e20c30 100644 Binary files a/storage/database/databasecopy.sqlite and b/storage/database/databasecopy.sqlite differ