A set of small fixes, courtesy of scrutinizer-ci

This commit is contained in:
James Cole 2016-01-27 19:35:00 +01:00
parent 9155c13e08
commit 28fdad9426
12 changed files with 69 additions and 51 deletions

View File

@ -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,

View File

@ -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' => [],

View File

@ -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' => [],

View File

@ -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,

View File

@ -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,

View File

@ -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));

View File

@ -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]));
}

View File

@ -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

View File

@ -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
{

View File

@ -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
{

View File

@ -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;
}
}

View File

@ -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
*