mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
All code for reminders based on piggy banks. I hope.
This commit is contained in:
@@ -136,7 +136,18 @@ class EloquentPiggybankRepository implements PiggybankRepositoryInterface
|
||||
$account = isset($data['account_id']) ? $accounts->find($data['account_id']) : null;
|
||||
|
||||
|
||||
|
||||
|
||||
$piggyBank = new \Piggybank($data);
|
||||
|
||||
if(!is_null($piggyBank->reminder) && is_null($piggyBank->startdate) && is_null($piggyBank->targetdate)) {
|
||||
|
||||
$piggyBank->errors()->add('reminder','Cannot create reminders without start ~ AND target date.');
|
||||
return $piggyBank;
|
||||
|
||||
}
|
||||
|
||||
|
||||
if($piggyBank->repeats && !isset($data['targetdate'])) {
|
||||
$piggyBank->errors()->add('targetdate','Target date is mandatory!');
|
||||
return $piggyBank;
|
||||
|
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace Firefly\Storage\Reminder;
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
/**
|
||||
* Class EloquentReminderRepository
|
||||
*
|
||||
* @package Firefly\Storage\Reminder
|
||||
*/
|
||||
class EloquentReminderRepository implements ReminderRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* @param \Reminder $reminder
|
||||
*
|
||||
* @return mixed|void
|
||||
*/
|
||||
public function deactivate(\Reminder $reminder)
|
||||
{
|
||||
$reminder->active = 0;
|
||||
$reminder->save();
|
||||
|
||||
return $reminder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
*
|
||||
* @return mixed|void
|
||||
*/
|
||||
public function find($id)
|
||||
{
|
||||
return \Reminder::find($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
$today = new Carbon;
|
||||
|
||||
return \Auth::user()->reminders()->validOn($today)->get();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: sander
|
||||
* Date: 23/08/14
|
||||
* Time: 20:59
|
||||
*/
|
||||
|
||||
namespace Firefly\Storage\Reminder;
|
||||
|
||||
|
||||
/**
|
||||
* Interface ReminderRepositoryInterface
|
||||
*
|
||||
* @package Firefly\Storage\Reminder
|
||||
*/
|
||||
interface ReminderRepositoryInterface {
|
||||
|
||||
/**
|
||||
* @param \Reminder $reminder
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function deactivate(\Reminder $reminder);
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get();
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function find($id);
|
||||
|
||||
}
|
@@ -36,6 +36,10 @@ class StorageServiceProvider extends ServiceProvider
|
||||
'Firefly\Storage\RecurringTransaction\EloquentRecurringTransactionRepository'
|
||||
);
|
||||
|
||||
$this->app->bind(
|
||||
'Firefly\Storage\Reminder\ReminderRepositoryInterface',
|
||||
'Firefly\Storage\Reminder\EloquentReminderRepository'
|
||||
);
|
||||
|
||||
$this->app->bind(
|
||||
'Firefly\Storage\Account\AccountRepositoryInterface',
|
||||
|
Reference in New Issue
Block a user