firefly-iii/app/controllers/ReminderController.php

61 lines
1.7 KiB
PHP
Raw Normal View History

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