firefly-iii/app/controllers/ReminderController.php

96 lines
2.4 KiB
PHP
Raw Normal View History

<?php
use FireflyIII\Exception\FireflyException;
/**
* Class ReminderController
*
*/
class ReminderController extends BaseController
{
2014-12-06 10:53:25 -06:00
/**
*
*/
2014-11-17 16:08:36 -06:00
public function __construct()
{
View::share('title', 'Reminders');
View::share('mainTitleIcon', 'fa-lightbulb-o');
}
2014-12-06 10:53:25 -06:00
/**
* @param Reminder $reminder
*
* @return \Illuminate\Http\RedirectResponse
* @throws FireflyException
*/
2014-12-06 10:34:39 -06:00
public function act(Reminder $reminder)
{
2014-12-06 10:34:39 -06:00
switch (get_class($reminder->remindersable)) {
default:
throw new FireflyException('Cannot act on reminder for ' . get_class($reminder->remindersable));
break;
2014-12-06 10:34:39 -06:00
break;
case 'Piggybank':
2014-12-06 10:34:39 -06:00
$amount = Reminders::amountForReminder($reminder);
2014-12-07 08:37:53 -06:00
$preFilled = [
2014-12-06 10:34:39 -06:00
'amount' => round($amount, 2),
'description' => 'Money for ' . $reminder->remindersable->name,
'piggybank_id' => $reminder->remindersable_id,
'account_to_id' => $reminder->remindersable->account_id
];
2014-12-07 08:37:53 -06:00
Session::flash('preFilled', $preFilled);
2014-12-06 10:34:39 -06:00
return Redirect::route('transactions.create', 'transfer');
break;
}
}
2014-12-06 10:53:25 -06:00
/**
* @param Reminder $reminder
*
* @return \Illuminate\Http\RedirectResponse
*/
2014-12-06 10:34:39 -06:00
public function dismiss(Reminder $reminder)
{
$reminder->active = 0;
$reminder->save();
2014-12-06 10:34:39 -06:00
Session::flash('success', 'Reminder dismissed');
return Redirect::route('index');
}
2014-12-06 10:34:39 -06:00
2014-12-06 10:53:25 -06:00
/**
* @param Reminder $reminder
*
* @return \Illuminate\Http\RedirectResponse
*/
2014-12-06 10:34:39 -06:00
public function notnow(Reminder $reminder)
{
2014-11-24 11:06:21 -06:00
$reminder->active = 0;
$reminder->notnow = 1;
$reminder->save();
2014-12-06 10:34:39 -06:00
Session::flash('success', 'Reminder dismissed');
2014-11-24 11:06:21 -06:00
return Redirect::route('index');
}
2014-12-06 10:34:39 -06:00
/**
* @param Reminder $reminder
2014-12-06 10:53:25 -06:00
*
* @return \Illuminate\View\View
2014-12-06 10:34:39 -06:00
*/
public function show(Reminder $reminder)
{
$amount = null;
if (get_class($reminder->remindersable) == 'Piggybank') {
$amount = Reminders::amountForReminder($reminder);
}
return View::make('reminders.show', compact('reminder', 'amount'));
}
2014-10-12 02:34:10 -05:00
}