mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-05 12:12:18 +00:00
Code removal. The code removed from these classes must move to respective services.
This commit is contained in:
66
app/Services/Internal/Update/BillUpdateService.php
Normal file
66
app/Services/Internal/Update/BillUpdateService.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/**
|
||||
* BillUpdateService.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Internal\Update;
|
||||
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Services\Internal\Support\BillServiceTrait;
|
||||
|
||||
/**
|
||||
* Class BillUpdateService
|
||||
*/
|
||||
class BillUpdateService
|
||||
{
|
||||
use BillServiceTrait;
|
||||
|
||||
/**
|
||||
* @param Bill $bill
|
||||
* @param array $data
|
||||
*/
|
||||
public function update(Bill $bill, array $data): Bill
|
||||
{
|
||||
|
||||
$matchArray = explode(',', $data['match']);
|
||||
$matchArray = array_unique($matchArray);
|
||||
$match = join(',', $matchArray);
|
||||
|
||||
$bill->name = $data['name'];
|
||||
$bill->match = $match;
|
||||
$bill->amount_min = $data['amount_min'];
|
||||
$bill->amount_max = $data['amount_max'];
|
||||
$bill->date = $data['date'];
|
||||
$bill->repeat_freq = $data['repeat_freq'];
|
||||
$bill->skip = $data['skip'];
|
||||
$bill->automatch = $data['automatch'];
|
||||
$bill->active = $data['active'];
|
||||
$bill->save();
|
||||
|
||||
// update note:
|
||||
if (isset($data['notes']) && null !== $data['notes']) {
|
||||
$this->updateNote($bill, strval($data['notes']));
|
||||
}
|
||||
|
||||
return $bill;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user