Skip to content

Commit 2acf9ba

Browse files
committed
Fix upcoming notes
1 parent 86589eb commit 2acf9ba

File tree

4 files changed

+43
-7
lines changed

4 files changed

+43
-7
lines changed

app/Http/Controllers/NoteController.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,17 +189,21 @@ public function getRemove($id)
189189
*
190190
* @return \Illuminate\Http\Response
191191
*/
192-
public function getUpcoming()
192+
public function getUpcoming($mode = null)
193193
{
194194
$perPage = Auth::user()->options['notes_per_page'];
195195

196-
$notes = Note::logged()
196+
$query = Note::logged()
197197
->where('status', 0)
198-
->whereNotNull('expires_at')
199-
->orderBy('expires_at', 'asc')
200-
->simplePaginate($perPage);
198+
->whereNotNull('expires_at');
201199

202-
return View::make('index', [
200+
if ($mode == 'no-expired') {
201+
$query->whereRaw('expires_at > NOW()');
202+
}
203+
204+
$notes = $query->orderBy('expires_at', 'asc')->simplePaginate($perPage);
205+
206+
return View::make('note.upcoming', [
203207
'notes' => $notes,
204208
'title' => trans('note.upcoming.title'),
205209
]);

app/Http/routes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@
4444

4545
Route::get('stats', ['as' => 'stats', 'uses' => 'StatisticsController@getIndex']);
4646

47-
Route::get('upcoming', ['as' => 'upcoming', 'uses' => 'NoteController@getUpcoming']);
47+
Route::get('upcoming/{mode?}', ['as' => 'upcoming', 'uses' => 'NoteController@getUpcoming']);

resources/lang/pl/note.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
],
4545
'removed' => 'Notatka została usunięta.',
4646
'upcoming' => [
47+
'no-expired' => 'Bez przekroczonych',
4748
'title' => 'Nadchodzące notatki',
4849
],
4950
];
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
@extends('app')
2+
3+
@section('content')
4+
<h2>
5+
@lang('note.upcoming.title')
6+
<a href="{!! route('upcoming', ['mode' => 'no-expired']) !!}" class="btn btn-default btn-sm">
7+
@lang('note.upcoming.no-expired')
8+
</a>
9+
</h2>
10+
11+
<div class="jscroll-container">
12+
@each('note.single', $notes, 'note')
13+
14+
{!! $notes->render() !!}
15+
</div>
16+
@stop
17+
18+
@section('footer')
19+
<script>
20+
$('.pager').hide();
21+
$('.jscroll-container').jscroll({
22+
loadingHtml: '<i class="fa fa-spinner fa-spin"></i>',
23+
padding: 10,
24+
nextSelector: '.pager a[rel="next"]',
25+
contentSelector: '.jscroll-container',
26+
callback: function () {
27+
$('.pager').hide();
28+
}
29+
});
30+
</script>
31+
@stop

0 commit comments

Comments
 (0)