mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-10 12:24:50 +00:00
Basic testing, not full coverage.
This commit is contained in:
@@ -26,6 +26,22 @@ class EloquentLimitRepository implements LimitRepositoryInterface
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Limit $limit
|
||||
* @param $data
|
||||
* @return mixed|void
|
||||
*/
|
||||
public function update(\Limit $limit, $data)
|
||||
{
|
||||
$limit->startdate = new Carbon($data['startdate']);
|
||||
$limit->repeat_freq = $data['period'];
|
||||
$limit->repeats = isset($data['repeats']) && $data['repeats'] == '1' ? 1 : 0;
|
||||
$limit->amount = floatval($data['amount']);
|
||||
|
||||
$limit->save();
|
||||
return $limit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $limitId
|
||||
*
|
||||
@@ -41,8 +57,8 @@ class EloquentLimitRepository implements LimitRepositoryInterface
|
||||
|
||||
/**
|
||||
* @param \Budget $budget
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
@@ -97,11 +113,11 @@ class EloquentLimitRepository implements LimitRepositoryInterface
|
||||
}
|
||||
// find existing:
|
||||
$count = \Limit::
|
||||
leftJoin('components', 'components.id', '=', 'limits.component_id')->where(
|
||||
'components.user_id', \Auth::user()->id
|
||||
)->where('startdate', $date->format('Y-m-d'))->where('component_id', $data['budget_id'])->where(
|
||||
'repeat_freq', $data['period']
|
||||
)->count();
|
||||
leftJoin('components', 'components.id', '=', 'limits.component_id')->where(
|
||||
'components.user_id', \Auth::user()->id
|
||||
)->where('startdate', $date->format('Y-m-d'))->where('component_id', $data['budget_id'])->where(
|
||||
'repeat_freq', $data['period']
|
||||
)->count();
|
||||
if ($count > 0) {
|
||||
\Session::flash('error', 'There already is an entry for these parameters.');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user