diff --git a/app/Generator/Chart/Account/ChartJsAccountChartGenerator.php b/app/Generator/Chart/Account/ChartJsAccountChartGenerator.php index 4006ff2c6e..5727478439 100644 --- a/app/Generator/Chart/Account/ChartJsAccountChartGenerator.php +++ b/app/Generator/Chart/Account/ChartJsAccountChartGenerator.php @@ -119,7 +119,7 @@ class ChartJsAccountChartGenerator implements AccountChartGenerator public function single(Account $account, Carbon $start, Carbon $end) { // language: - $format = trans('config.month_and_day'); + $format = (string)trans('config.month_and_day'); $data = [ 'count' => 1, diff --git a/app/Generator/Chart/Bill/ChartJsBillChartGenerator.php b/app/Generator/Chart/Bill/ChartJsBillChartGenerator.php index ff1c9b6150..8ccbcfed81 100644 --- a/app/Generator/Chart/Bill/ChartJsBillChartGenerator.php +++ b/app/Generator/Chart/Bill/ChartJsBillChartGenerator.php @@ -49,7 +49,7 @@ class ChartJsBillChartGenerator implements BillChartGenerator */ public function single(Bill $bill, Collection $entries) { - $format = trans('config.month'); + $format = (string)trans('config.month'); $data = [ 'count' => 3, 'labels' => [], diff --git a/app/Generator/Chart/Budget/ChartJsBudgetChartGenerator.php b/app/Generator/Chart/Budget/ChartJsBudgetChartGenerator.php index 65db28db6b..1c001aa3aa 100644 --- a/app/Generator/Chart/Budget/ChartJsBudgetChartGenerator.php +++ b/app/Generator/Chart/Budget/ChartJsBudgetChartGenerator.php @@ -149,7 +149,7 @@ class ChartJsBudgetChartGenerator implements BudgetChartGenerator public function year(Collection $budgets, Collection $entries) { // language: - $format = trans('config.month'); + $format = (string)trans('config.month'); $data = [ 'labels' => [], diff --git a/app/Generator/Chart/Category/ChartJsCategoryChartGenerator.php b/app/Generator/Chart/Category/ChartJsCategoryChartGenerator.php index 3c744cb9de..ee1b828ded 100644 --- a/app/Generator/Chart/Category/ChartJsCategoryChartGenerator.php +++ b/app/Generator/Chart/Category/ChartJsCategoryChartGenerator.php @@ -59,7 +59,7 @@ class ChartJsCategoryChartGenerator implements CategoryChartGenerator { // language: - $format = trans('config.month'); + $format = (string)trans('config.month'); $data = [ 'count' => 0, @@ -170,7 +170,7 @@ class ChartJsCategoryChartGenerator implements CategoryChartGenerator { // language: - $format = trans('config.month'); + $format = (string)trans('config.month'); $data = [ 'count' => 0, diff --git a/app/Generator/Chart/Report/ChartJsReportChartGenerator.php b/app/Generator/Chart/Report/ChartJsReportChartGenerator.php index 3b64f1a8b1..3a59ce243a 100644 --- a/app/Generator/Chart/Report/ChartJsReportChartGenerator.php +++ b/app/Generator/Chart/Report/ChartJsReportChartGenerator.php @@ -84,7 +84,7 @@ class ChartJsReportChartGenerator implements ReportChartGenerator public function yearInOut(Collection $entries) { // language: - $format = trans('config.month'); + $format = (string)trans('config.month'); $data = [ 'count' => 2, diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index ae59eb0af3..08328d8884 100755 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -22,9 +22,9 @@ class Controller extends BaseController { use AuthorizesRequests, DispatchesJobs, ValidatesRequests; - /** @var string|\Symfony\Component\Translation\TranslatorInterface */ + /** @var string */ protected $monthAndDayFormat; - /** @var string|\Symfony\Component\Translation\TranslatorInterface */ + /** @var string */ protected $monthFormat; /** @@ -40,8 +40,8 @@ class Controller extends BaseController if (Auth::check()) { $pref = Preferences::get('language', env('DEFAULT_LANGUAGE', 'en_US')); $lang = $pref->data; - $this->monthFormat = trans('config.month'); - $this->monthAndDayFormat = trans('config.month_and_day'); + $this->monthFormat = (string)trans('config.month'); + $this->monthAndDayFormat = (string)trans('config.month_and_day'); App::setLocale($lang); Carbon::setLocale(substr($lang, 0, 2)); diff --git a/app/Http/breadcrumbs.php b/app/Http/breadcrumbs.php index fed6bd4844..71b894a813 100644 --- a/app/Http/breadcrumbs.php +++ b/app/Http/breadcrumbs.php @@ -355,7 +355,10 @@ Breadcrumbs::register( $breadcrumbs->parent('reports.index'); $monthFormat = (string)trans('config.month_and_day'); - $title = (string)trans('firefly.report_' . $reportType, ['start' => $start->formatLocalized($monthFormat), 'end' => $end->formatLocalized($monthFormat)]); + $title = (string)trans( + 'firefly.report_' . $reportType, + ['start' => $start->formatLocalized($monthFormat), 'end' => $end->formatLocalized($monthFormat)] + ); $breadcrumbs->push($title, route('reports.report', [$reportType, $start->format('Ymd'), $end->format('Ymd'), $accountIds])); } diff --git a/app/Models/Account.php b/app/Models/Account.php index ee271f7f67..6bb5b82eda 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -42,8 +42,11 @@ class Account extends Model { use SoftDeletes, ValidatingTrait; + /** @var array */ protected $dates = ['created_at', 'updated_at', 'deleted_at']; + /** @var array */ protected $fillable = ['user_id', 'account_type_id', 'name', 'active', 'virtual_balance', 'iban']; + /** @var array */ protected $hidden = ['virtual_balance_encrypted', 'encrypted']; protected $rules = [ @@ -52,6 +55,8 @@ class Account extends Model 'name' => 'required', 'active' => 'required|boolean', ]; + /** @var bool */ + private $joinedAccountTypes; /** * @param array $fields diff --git a/app/Models/Budget.php b/app/Models/Budget.php index 7fccdec4f9..81a3c49395 100644 --- a/app/Models/Budget.php +++ b/app/Models/Budget.php @@ -26,6 +26,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; * @property string $dateFormatted * @property string $budgeted * @property float $amount + * @property Carbon $date */ class Budget extends Model { diff --git a/app/Models/Category.php b/app/Models/Category.php index 78f0611283..7fc528ca5b 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -23,6 +23,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; * @property-read User $user * @property string $dateFormatted * @property float $spent + * @property Carbon $lastActivity */ class Category extends Model { diff --git a/app/Models/Tag.php b/app/Models/Tag.php index f9894ef980..aae30f866b 100644 --- a/app/Models/Tag.php +++ b/app/Models/Tag.php @@ -27,11 +27,12 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; * @property integer $zoomLevel * @property-read Collection|TransactionJournal[] $transactionjournals * @property-read User $user + * @property int $account_id */ class Tag extends Model { - protected $fillable = ['user_id', 'tag', 'date', 'description', 'longitude', 'latitude', 'zoomLevel', 'tagMode']; protected $dates = ['created_at', 'updated_at', 'date']; + protected $fillable = ['user_id', 'tag', 'date', 'description', 'longitude', 'latitude', 'zoomLevel', 'tagMode']; /** * @param array $fields @@ -66,30 +67,18 @@ class Tag extends Model } /** - * Save the model to the database. + * @param Tag $value * - * @param array $options - * - * @return bool + * @return Tag */ - public function save(array $options = []) + public static function routeBinder(Tag $value) { - foreach ($this->transactionjournals()->get() as $journal) { - $count = $journal->tags()->count(); - $journal->tag_count = $count; - $journal->save(); + if (Auth::check()) { + if ($value->user_id == Auth::user()->id) { + return $value; + } } - - return parent::save($options); - } - - /** - * @codeCoverageIgnore - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany - */ - public function transactionjournals() - { - return $this->belongsToMany('FireflyIII\Models\TransactionJournal'); + throw new NotFoundHttpException; } /** @@ -120,6 +109,24 @@ class Tag extends Model return Crypt::decrypt($value); } + /** + * Save the model to the database. + * + * @param array $options + * + * @return bool + */ + public function save(array $options = []) + { + foreach ($this->transactionjournals()->get() as $journal) { + $count = $journal->tags()->count(); + $journal->tag_count = $count; + $journal->save(); + } + + return parent::save($options); + } + /** * @codeCoverageIgnore * @@ -140,6 +147,15 @@ class Tag extends Model $this->attributes['tag'] = Crypt::encrypt($value); } + /** + * @codeCoverageIgnore + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + */ + public function transactionjournals() + { + return $this->belongsToMany('FireflyIII\Models\TransactionJournal'); + } + /** * @codeCoverageIgnore * @return \Illuminate\Database\Eloquent\Relations\BelongsTo @@ -150,20 +166,4 @@ class Tag extends Model } - /** - * @param Tag $value - * - * @return Tag - */ - public static function routeBinder(Tag $value) - { - if (Auth::check()) { - if ($value->user_id == Auth::user()->id) { - return $value; - } - } - throw new NotFoundHttpException; - } - - } diff --git a/app/Models/TransactionJournal.php b/app/Models/TransactionJournal.php index b49f65bc3f..d24cadb163 100644 --- a/app/Models/TransactionJournal.php +++ b/app/Models/TransactionJournal.php @@ -49,6 +49,7 @@ use Watson\Validating\ValidatingTrait; * @property float $journalAmount * @property int $account_id * @property int $budget_id + * @property string $account_name * @method static Builder|TransactionJournal accountIs($account) * @method static Builder|TransactionJournal after($date) * @method static Builder|TransactionJournal before($date) @@ -61,12 +62,16 @@ class TransactionJournal extends Model use SoftDeletes, ValidatingTrait; - protected $dates = ['created_at', 'updated_at', 'date', 'deleted_at']; + /** @var array */ + protected $dates = ['created_at', 'updated_at', 'date', 'deleted_at']; + /** @var array */ protected $fillable - = ['user_id', 'transaction_type_id', 'bill_id', 'transaction_currency_id', 'description', 'completed', 'date', 'encrypted', 'tag_count']; + = ['user_id', 'transaction_type_id', 'bill_id', 'transaction_currency_id', 'description', 'completed', 'date', 'encrypted', 'tag_count']; + /** @var array */ protected $hidden = ['encrypted']; + /** @var array */ protected $rules - = [ + = [ 'user_id' => 'required|exists:users,id', 'transaction_type_id' => 'required|exists:transaction_types,id', 'bill_id' => 'exists:bills,id', @@ -77,6 +82,9 @@ class TransactionJournal extends Model 'encrypted' => 'required|boolean', ]; + /** @var bool */ + private $joinedTransactionTypes; + /** * @param $value *