View single reminder.

This commit is contained in:
James Cole 2015-03-07 09:29:43 +01:00
parent 93996ada96
commit 081ff3ff55
4 changed files with 79 additions and 15 deletions

View File

@ -5,7 +5,6 @@ use Carbon\Carbon;
use FireflyIII\Helpers\Reminders\ReminderHelperInterface;
use FireflyIII\Http\Requests;
use FireflyIII\Models\Reminder;
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
use Redirect;
use URL;
@ -18,6 +17,19 @@ class ReminderController extends Controller
{
/**
* @param Reminder $reminder
*/
public function dismiss(Reminder $reminder)
{
$reminder->notnow = true;
$reminder->save();
return Redirect::to(URL::previous());
}
/**
*
*/
@ -26,11 +38,13 @@ class ReminderController extends Controller
$reminders = Auth::user()->reminders()->get();
$reminders->each(function(Reminder $reminder) use ($helper) {
$reminder->description = $helper->getReminderText($reminder);
});
$reminders->each(
function (Reminder $reminder) use ($helper) {
$reminder->description = $helper->getReminderText($reminder);
}
);
$today = new Carbon;
$today = new Carbon;
// active reminders:
$active = $reminders->filter(
function (Reminder $reminder) use ($today) {
@ -78,18 +92,18 @@ class ReminderController extends Controller
*/
public function show(Reminder $reminder)
{
$title = 'Reminder';
$mainTitleIcon = 'fa-clock-o';
if ($reminder->notnow === true) {
$subTitle = 'Dismissed reminder';
} else {
$subTitle = 'Reminder';
}
$subTitle .= ' for piggy bank "' . $reminder->remindersable->name . '"';
}
/**
* @param Reminder $reminder
*/
public function dismiss(Reminder $reminder)
{
$reminder->notnow = true;
$reminder->save();
return Redirect::to(URL::previous());
return view('reminders.show', compact('reminder', 'title', 'subTitle', 'mainTitleIcon'));
}

View File

@ -7,6 +7,7 @@ use FireflyIII\Models\Budget;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\Bill;
use FireflyIII\Models\Category;
use FireflyIII\Models\Reminder;
use FireflyIII\Models\LimitRepetition;
use FireflyIII\Models\PiggyBank;
@ -239,8 +240,17 @@ Breadcrumbs::register(
// reminders
Breadcrumbs::register(
'reminders.show', function (Generator $breadcrumbs, Reminder $reminder) {
'reminders.index', function (Generator $breadcrumbs) {
$breadcrumbs->parent('home');
$breadcrumbs->push('Reminders', route('reminders.index'));
}
);
// reminders
Breadcrumbs::register(
'reminders.show', function (Generator $breadcrumbs, Reminder $reminder) {
$breadcrumbs->parent('reminders.index');
$breadcrumbs->push('Reminder #' . $reminder->id, route('reminders.show', $reminder->id));
}

View File

@ -4,12 +4,14 @@
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
<div class="panel panel-default">
<div class="panel-heading">
<a href="{{route('reminders.show',$reminder->id)}}">
@if($reminder->notnow === true)
Dismissed reminder
@else
Reminder
@endif
for piggy bank "{{$reminder->remindersable->name}}"
</a>
</div>
<div class="panel-body">
<p>

View File

@ -0,0 +1,38 @@
@extends('layouts.default')
@section('content')
{!! Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName(), $reminder) !!}
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
<div class="panel panel-default">
<div class="panel-heading">
<a href="{{route('reminders.show',$reminder->id)}}">
@if($reminder->notnow === true)
Dismissed reminder
@else
Reminder
@endif
for piggy bank "{{$reminder->remindersable->name}}"
</a>
</div>
<div class="panel-body">
<p>
Active between {{$reminder->startdate->format('jS F Y')}}
and {{$reminder->enddate->format('jS F Y')}}.
</p>
@if(isset($reminder->description))
<p>{!! $reminder->description !!}</p>
@endif
</div>
<div class="panel-footer">
<div class="btn-group">
@if($reminder->active === true)
<a class="btn btn-warning" href="{{route('reminders.dismiss',$reminder->id)}}">Dismiss</a>
<a class="btn btn-success" href="#">Act</a>
@endif
</div>
</div>
</div>
</div>
</div>
@stop