Skip to content

Commit ca6261f

Browse files
committed
Tickets List View Composer
1 parent 38976d2 commit ca6261f

File tree

6 files changed

+57
-19
lines changed

6 files changed

+57
-19
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace TeachMe\Http\ViewComposers;
4+
5+
use Illuminate\Support\Facades\Lang;
6+
use Illuminate\Support\Facades\Route;
7+
8+
class TicketsListComposer {
9+
10+
public function compose($view)
11+
{
12+
$view->title = trans(Route::currentRouteName() . '_title');
13+
$view->text_total = Lang::choice(
14+
'tickets.total',
15+
$view->tickets->total(),
16+
['title' => strtolower($view->title)]
17+
);
18+
}
19+
20+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php namespace TeachMe\Providers;
2+
3+
use Illuminate\Support\ServiceProvider;
4+
5+
class ViewServiceProvider extends ServiceProvider {
6+
7+
/**
8+
* Bootstrap the application services.
9+
*
10+
* @return void
11+
*/
12+
public function boot()
13+
{
14+
view()->composer(
15+
'tickets/list',
16+
'TeachMe\Http\ViewComposers\TicketsListComposer'
17+
);
18+
}
19+
20+
/**
21+
* Register the application services.
22+
*
23+
* @return void
24+
*/
25+
public function register()
26+
{
27+
//
28+
}
29+
30+
}

config/app.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@
150150
'TeachMe\Providers\EventServiceProvider',
151151
'TeachMe\Providers\RouteServiceProvider',
152152
'TeachMe\Providers\HtmlServiceProvider',
153+
'TeachMe\Providers\ViewServiceProvider',
153154

154155
],
155156

resources/lang/es/tickets.php

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,9 @@
77
'closed_title' => 'Tutoriales',
88
'popular_title' => 'Solicitudes populares',
99

10-
'latest_total' => '{0} No hay solicitudes recientes'
11-
. '|{1} Sólo hay una solicitud reciente'
12-
. '|[2,Inf] Hay :count solicitudes recientes',
13-
14-
'open_total' => '{0} No hay solicitudes abiertas'
15-
. '|{1} Sólo hay una solicitud abierta'
16-
. '|[2,Inf] Hay :count solicitudes abiertas',
17-
18-
'closed_total' => '{0} No hay tutoriales'
19-
. '|{1} Sólo hay un tutorial'
20-
. '|[2,Inf] Hay :count tutoriales',
21-
22-
'popular_total' => '{0} No hay solicitudes populares'
23-
. '|{1} Sólo hay una solicitud popular'
24-
. '|[2,Inf] Hay :count solicitudes populares',
10+
'total' => '{0} No hay :title'
11+
. '|{1} Sólo hay una :title'
12+
. '|[2,Inf] Hay :count :title',
2513

2614
'status' => array(
2715
'open' => 'Abierta',

resources/views/layout.blade.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
<!DOCTYPE html>
32
<html lang="en">
43
<head>
@@ -34,7 +33,7 @@
3433
<span class="icon-bar"></span>
3534
<span class="icon-bar"></span>
3635
</button>
37-
<a class="navbar-brand" href="http://duilio.me" target="_blank">duilio.me</a>
36+
<a class="navbar-brand" href="https://styde.net" target="_blank">Styde.net</a>
3837
</div>
3938

4039
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">

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-
{{ $title = trans(Route::currentRouteName() . '_title') }}
10+
{{ $title }}
1111
<a href="{{ route('tickets.create') }}" class="btn btn-primary">
1212
Nueva solicitud
1313
</a>
1414
</h1>
1515

1616
<p class="label label-info news">
17-
{{ Lang::choice(Route::currentRouteName() . '_total', $tickets->total()) }}
17+
{{ $text_total }}
1818
</p>
1919

2020
@foreach($tickets as $ticket)

0 commit comments

Comments
 (0)