firefly-iii/app/Http/Controllers/ReminderController.php

89 lines
2.2 KiB
PHP
Raw Normal View History

2015-03-06 13:33:23 -06:00
<?php namespace FireflyIII\Http\Controllers;
use Auth;
2015-03-07 02:21:06 -06:00
use FireflyIII\Helpers\Reminders\ReminderHelperInterface;
2015-03-06 13:33:23 -06:00
use FireflyIII\Models\Reminder;
2015-05-03 02:55:22 -05:00
use FireflyIII\Repositories\Reminder\ReminderRepositoryInterface;
2015-03-07 02:21:06 -06:00
use Redirect;
2015-03-08 14:20:58 -05:00
use Session;
2015-03-10 11:26:31 -05:00
use URL;
2015-03-07 02:21:06 -06:00
/**
* Class ReminderController
*
* @package FireflyIII\Http\Controllers
*/
2015-03-06 13:33:23 -06:00
class ReminderController extends Controller
{
2015-03-08 14:20:58 -05:00
/**
* @param Reminder $reminder
*/
public function act(Reminder $reminder)
{
$data = [
'description' => 'Money for piggy bank "' . $reminder->remindersable->name . '"',
'amount' => round($reminder->metadata->perReminder, 2),
'account_to_id' => $reminder->remindersable->account_id,
2015-03-10 11:26:31 -05:00
'piggy_bank_id' => $reminder->remindersable_id,
'reminder_id' => $reminder->id,
2015-03-08 14:20:58 -05:00
];
2015-03-10 11:26:31 -05:00
Session::flash('_old_input', $data);
2015-03-08 14:20:58 -05:00
2015-03-10 11:26:31 -05:00
return Redirect::route('transactions.create', 'transfer');
2015-03-08 14:20:58 -05:00
}
2015-03-07 02:29:43 -06:00
/**
* @param Reminder $reminder
*/
public function dismiss(Reminder $reminder)
{
$reminder->notnow = true;
$reminder->save();
return Redirect::to(URL::previous());
}
2015-03-06 13:33:23 -06:00
/**
*
*/
2015-05-03 02:55:22 -05:00
public function index(ReminderRepositoryInterface $repository)
2015-03-06 13:33:23 -06:00
{
2015-05-03 02:55:22 -05:00
$active = $repository->getActiveReminders();
$expired = $repository->getExpiredReminders();
$inactive = $repository->getInactiveReminders();
$dismissed = $repository->getDismissedReminders();
2015-03-06 13:33:23 -06:00
$title = 'Reminders';
$mainTitleIcon = 'fa-clock-o';
return view('reminders.index', compact('dismissed', 'expired', 'inactive', 'active', 'title', 'mainTitleIcon'));
}
/**
* @param Reminder $reminder
*/
public function show(Reminder $reminder)
{
2015-03-08 14:20:58 -05:00
$title = 'Reminder';
2015-03-07 02:29:43 -06:00
$mainTitleIcon = 'fa-clock-o';
if ($reminder->notnow === true) {
$subTitle = 'Dismissed reminder';
} else {
$subTitle = 'Reminder';
}
$subTitle .= ' for piggy bank "' . $reminder->remindersable->name . '"';
2015-03-06 13:33:23 -06:00
2015-03-07 02:29:43 -06:00
return view('reminders.show', compact('reminder', 'title', 'subTitle', 'mainTitleIcon'));
2015-03-07 02:21:06 -06:00
}
2015-03-06 13:33:23 -06:00
}