Skip to content

Commit 288eaba

Browse files
committed
Open and closed ticket pages working (homework from lesson 2.8)
1 parent 2f91bec commit 288eaba

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

app/Http/Controllers/TicketsController.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ class TicketsController extends Controller {
1111
public function latest()
1212
{
1313
$tickets = Ticket::orderBy('created_at', 'DESC')->paginate(20);
14-
15-
return view('tickets/list', compact('tickets'));
14+
$title = 'Solicitudes recientes';
15+
return view('tickets/list', compact('tickets', 'title'));
1616
}
1717

1818
public function popular()
@@ -22,12 +22,16 @@ public function popular()
2222

2323
public function open()
2424
{
25-
return view('tickets/list');
25+
$tickets = Ticket::where('status', 'open')->orderBy('created_at', 'DESC')->paginate(20);
26+
$title = 'Solicitudes abiertas';
27+
return view('tickets/list', compact('tickets', 'title'));
2628
}
2729

2830
public function closed()
2931
{
30-
return view('tickets/list');
32+
$tickets = Ticket::where('status', 'closed')->orderBy('created_at', 'DESC')->paginate(20);
33+
$title = 'Tutoriales';
34+
return view('tickets/list', compact('tickets', 'title'));
3135
}
3236

3337
public function details($id)

resources/views/tickets/list.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
<div class="col-md-10 col-md-offset-1">
88
<div class="row">
99
<h1>
10-
Solicitudes Recientes
10+
{{ $title }}
1111
<a href="#" class="btn btn-primary">
1212
Nueva solicitud
1313
</a>
1414
</h1>
1515

1616
<p class="label label-info news">
17-
Hay {{ $tickets->total() }} Solicitudes Recientes
17+
Hay {{ $tickets->total() }} {{ $title }}
1818
</p>
1919

2020
@foreach($tickets as $ticket)

0 commit comments

Comments
 (0)