mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-19 04:49:30 +00:00
There's a giant mix brewing between "old" code, bad code and not implemented exceptions. I suspect the next change will be to cut out all old stuff, throw a lot of NotImplementedExceptions and get going.
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace FireflyIII\Database\Ifaces;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Interface AccountInterface
|
||||
*
|
||||
* @package FireflyIII\Database
|
||||
*/
|
||||
interface RecurringTransactionInterface
|
||||
{
|
||||
}
|
||||
139
app/lib/FireflyIII/Database/RecurringTransaction.php
Normal file
139
app/lib/FireflyIII/Database/RecurringTransaction.php
Normal file
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
|
||||
namespace FireflyIII\Database;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Database\Ifaces\RecurringTransactionInterface;
|
||||
use FireflyIII\Database\Ifaces\CommonDatabaseCalls;
|
||||
use FireflyIII\Database\Ifaces\CUD;
|
||||
use FireflyIII\Exception\NotImplementedException;
|
||||
use Illuminate\Support\MessageBag;
|
||||
use LaravelBook\Ardent\Ardent;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Class Account
|
||||
*
|
||||
* @package FireflyIII\Database
|
||||
*/
|
||||
class RecurringTransaction implements CUD, CommonDatabaseCalls, RecurringTransactionInterface
|
||||
{
|
||||
use SwitchUser;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->setUser(\Auth::user());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Ardent $model
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function destroy(Ardent $model)
|
||||
{
|
||||
// TODO: Implement destroy() method.
|
||||
throw new NotImplementedException;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a model. Returns an array containing MessageBags
|
||||
* errors/warnings/successes.
|
||||
*
|
||||
* @param Ardent $model
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function validateObject(Ardent $model)
|
||||
{
|
||||
// TODO: Implement validateObject() method.
|
||||
throw new NotImplementedException;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates an array. Returns an array containing MessageBags
|
||||
* errors/warnings/successes.
|
||||
*
|
||||
* @param array $model
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function validate(array $model)
|
||||
{
|
||||
// TODO: Implement validate() method.
|
||||
throw new NotImplementedException;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return Ardent
|
||||
*/
|
||||
public function store(array $data)
|
||||
{
|
||||
// TODO: Implement store() method.
|
||||
throw new NotImplementedException;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Ardent $model
|
||||
* @param array $data
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function update(Ardent $model, array $data)
|
||||
{
|
||||
// TODO: Implement update() method.
|
||||
throw new NotImplementedException;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an object with id $id.
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return Ardent
|
||||
*/
|
||||
public function find($id)
|
||||
{
|
||||
// TODO: Implement find() method.
|
||||
throw new NotImplementedException;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all objects.
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
return $this->getUser()->recurringtransactions()->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $ids
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getByIds(array $ids)
|
||||
{
|
||||
// TODO: Implement getByIds() method.
|
||||
throw new NotImplementedException;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds an account type using one of the "$what"'s: expense, asset, revenue, opening, etc.
|
||||
*
|
||||
* @param $what
|
||||
*
|
||||
* @return \AccountType|null
|
||||
*/
|
||||
public function findByWhat($what)
|
||||
{
|
||||
// TODO: Implement findByWhat() method.
|
||||
throw new NotImplementedException;
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ namespace FireflyIII\Database;
|
||||
|
||||
/**
|
||||
* Class User
|
||||
*
|
||||
* @package FireflyIII\Database
|
||||
*/
|
||||
class User
|
||||
@@ -12,14 +13,15 @@ class User
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return bool|\User
|
||||
*/
|
||||
public function register(array $data)
|
||||
{
|
||||
$user = new \User;
|
||||
$user->email = isset($data['email']) ? $data['email'] : null;
|
||||
$user = new \User;
|
||||
$user->email = isset($data['email']) ? $data['email'] : null;
|
||||
$user->migrated = 0;
|
||||
$user->reset = \Str::random(32);
|
||||
$user->reset = \Str::random(32);
|
||||
$user->password = \Hash::make(\Str::random(12));
|
||||
|
||||
if (!$user->save()) {
|
||||
@@ -34,6 +36,20 @@ class User
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \User $user
|
||||
* @param $password
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function updatePassword(\User $user, $password)
|
||||
{
|
||||
$user->password = $password;
|
||||
$user->forceSave();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $mail
|
||||
*
|
||||
|
||||
@@ -24,7 +24,7 @@ class Filter
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function setSessionRangeValue()
|
||||
public function setSessionRangeValue()
|
||||
{
|
||||
if (!is_null(\Session::get('range'))) {
|
||||
$range = \Session::get('range');
|
||||
@@ -221,7 +221,7 @@ class Filter
|
||||
* @return Carbon
|
||||
* @throws FireflyException
|
||||
*/
|
||||
protected function previous($range, Carbon $date)
|
||||
public function previous($range, Carbon $date)
|
||||
{
|
||||
switch ($range) {
|
||||
default:
|
||||
@@ -262,7 +262,7 @@ class Filter
|
||||
* @return Carbon
|
||||
* @throws FireflyException
|
||||
*/
|
||||
protected function next($range, Carbon $date)
|
||||
public function next($range, Carbon $date)
|
||||
{
|
||||
switch ($range) {
|
||||
case '1D':
|
||||
|
||||
64
app/lib/FireflyIII/Shared/Toolkit/Navigation.php
Normal file
64
app/lib/FireflyIII/Shared/Toolkit/Navigation.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace FireflyIII\Shared\Toolkit;
|
||||
|
||||
/**
|
||||
* Class Navigation
|
||||
*
|
||||
* @package FireflyIII\Shared\Toolkit
|
||||
*/
|
||||
class Navigation
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
* @throws \Firefly\Exception\FireflyException
|
||||
*/
|
||||
public function next()
|
||||
{
|
||||
/*
|
||||
* Get the start date and the range from the session
|
||||
*/
|
||||
|
||||
$filter = new Filter;
|
||||
|
||||
$range = $filter->setSessionRangeValue();
|
||||
$start = \Session::get('start');
|
||||
|
||||
/*
|
||||
* Add some period to $start.
|
||||
*/
|
||||
$next = $filter->next($range, clone $start);
|
||||
|
||||
/*
|
||||
* Save in session:
|
||||
*/
|
||||
\Session::put('start', $next);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
* @throws \Firefly\Exception\FireflyException
|
||||
*/
|
||||
public function prev()
|
||||
{
|
||||
/*
|
||||
* Get the start date and the range from the session
|
||||
*/
|
||||
$filter = new Filter;
|
||||
|
||||
$range = $filter->setSessionRangeValue();
|
||||
$start = \Session::get('start');
|
||||
|
||||
/*
|
||||
* Substract some period to $start.
|
||||
*/
|
||||
$prev = $filter->previous($range, clone $start);
|
||||
|
||||
/*
|
||||
* Save in session:
|
||||
*/
|
||||
\Session::put('start', $prev);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user