diff options
| author | horus | 2019-05-13 15:32:29 +0200 |
|---|---|---|
| committer | horus | 2019-05-13 15:32:29 +0200 |
| commit | 0d4c4fbabc4469d533ca309d3342df0bb92fc4d6 (patch) | |
| tree | 0fd71bf7b03f56e34d1650e5fc8b20af81969148 /site | |
| parent | 07a828530d578fd4383ff59a1446db9c6b009994 (diff) | |
| download | alkobote-0d4c4fbabc4469d533ca309d3342df0bb92fc4d6.tar.gz | |
Adds custom pagination. (site)
Diffstat (limited to 'site')
| -rw-r--r-- | site/app/Http/Controllers/FKOfferController.php | 3 | ||||
| -rw-r--r-- | site/app/Http/Controllers/FKSearchController.php | 2 | ||||
| -rw-r--r-- | site/resources/views/fk-offer.blade.php | 24 | ||||
| -rw-r--r-- | site/resources/views/fk-search.blade.php | 18 | ||||
| -rw-r--r-- | site/resources/views/paginate.blade.php | 36 |
5 files changed, 60 insertions, 23 deletions
diff --git a/site/app/Http/Controllers/FKOfferController.php b/site/app/Http/Controllers/FKOfferController.php index e6c7c6a..e7559a9 100644 --- a/site/app/Http/Controllers/FKOfferController.php +++ b/site/app/Http/Controllers/FKOfferController.php @@ -57,7 +57,8 @@ class FKOfferController extends Controller { * Database query */ $view_name = \Request::route()->getName(); - $data = DB::table($view_name . '_view')->whereNotNull('url')->orderBy($sort_by, $order_by)->simplePaginate(10); + #$data = DB::table($view_name . '_view')->whereNotNull('url')->orderBy($sort_by, $order_by)->simplePaginate(10); + $data = DB::table($view_name . '_view')->whereNotNull('url')->orderBy($sort_by, $order_by)->paginate(10); $count = DB::table($view_name . '_view')->whereNotNull('url')->count(); $rss_feed = "/angebote/" . $view_name . "/feed/"; diff --git a/site/app/Http/Controllers/FKSearchController.php b/site/app/Http/Controllers/FKSearchController.php index a148bba..efa6c8a 100644 --- a/site/app/Http/Controllers/FKSearchController.php +++ b/site/app/Http/Controllers/FKSearchController.php @@ -60,7 +60,7 @@ class FKSearchController extends Controller { $query = Input::get("q"); $q = "%" . Utility::escapeLike($query) . "%"; - $data = DB::table('all_view')->whereNotNull('url')->where('name', 'like', $q)->orWhere('spirit_type', 'like', $q)->orWhere('shop', 'like', $q)->orderBy($sort_by, $order_by)->simplePaginate(20); + $data = DB::table('all_view')->whereNotNull('url')->where('name', 'like', $q)->orWhere('spirit_type', 'like', $q)->orWhere('shop', 'like', $q)->orderBy($sort_by, $order_by)->paginate(20); $count = DB::table('all_view')->whereNotNull('url')->where('name', 'like', $q)->orWhere('spirit_type', 'like', $q)->orWhere('shop', 'like', $q); $query_string = ""; diff --git a/site/resources/views/fk-offer.blade.php b/site/resources/views/fk-offer.blade.php index 0c344ae..13b9196 100644 --- a/site/resources/views/fk-offer.blade.php +++ b/site/resources/views/fk-offer.blade.php @@ -1,11 +1,11 @@ @extends('layouts.fk-base') @section('header') -{{ ucfirst($title) }} +{{ ucwords($title) }} @endsection @section('feed') - {!! Feed::link(secure_url($rss_feed) . "/", 'atom', 'Feed von ' . ucfirst($spirit_type) . '-Angeboten', 'de') !!} + {!! Feed::link(secure_url($rss_feed) . "/", 'atom', 'Feed von ' . ucwords($spirit_type) . '-Angeboten', 'de') !!} @endsection @section('content') @@ -18,8 +18,8 @@ } else if ( "Andere Angebote" == $spirit_type ){ $header = "Aktuelle Spirituosen-Sonderangebote"; } else { - $header = "Aktuelle " . ucfirst($spirit_type) . "-Angebote"; - $header_text = "Du bist auf der Suche nach einem neuen Lieblings" . $spirit_type . "? Hier sind alle aktuell reduzierten " . ucfirst($spirit_type) . "s aufgelistet. Happy Dramming!"; + $header = "Aktuelle " . ucwords($spirit_type) . "-Angebote"; + $header_text = "Du bist auf der Suche nach einem neuen Lieblings" . $spirit_type . "? Hier sind alle aktuell reduzierten " . ucwords($spirit_type) . "s aufgelistet. Happy Dramming!"; } ?> <div class="container"> @@ -28,7 +28,7 @@ <!-- Breadcrumb NavXT 6.2.1 --> <li class="home breadcrumb-item"><span property="itemListElement" typeof="ListItem"><a property="item" typeof="WebPage" title="Gehe zur Startseite: Fuselkönig.de" href="https://www.fuselkoenig.de" class="home"><span property="name">Startseite</span></a><meta property="position" content="1"></span></li> <li class="post post-angebote-archive breadcrumb-item"><span property="itemListElement" typeof="ListItem"><a property="item" typeof="WebPage" title="Schau dir Angebote an." href="/angebote/" class="post post-angebote-archive"><span property="name">Angebote</span></a><meta property="position" content="2"></span></li> -<li class="archive taxonomy type current-item breadcrumb-item active" aria-current="page"><span property="itemListElement" typeof="ListItem"><span property="name">{{ ucfirst($spirit_type) }}</span><meta property="position" content="3"></span></li> +<li class="archive taxonomy type current-item breadcrumb-item active" aria-current="page"><span property="itemListElement" typeof="ListItem"><span property="name">{{ ucwords($spirit_type) }}</span><meta property="position" content="3"></span></li> </ol> </nav> </div> @@ -47,13 +47,13 @@ </div> </header><!-- .page-header --> - {{ $data->appends(Input::except('page'))->links() }} + {{ $data->appends(Input::except('page'))->links('paginate') }} <?php /* <div class="jumbotron p-3 p-md-5 text-white rounded bg-dark bbg-white ttext-dark box-shadow"> <div class="col-md-6 px-0"> - <h1 class="display-4 font-italic">{{ ucfirst($spirit_type) }} <span class="text-mute ml-10">({{$count}} Angebote)</span><!-- --></h1> + <h1 class="display-4 font-italic">{{ ucwords($spirit_type) }} <span class="text-mute ml-10">({{$count}} Angebote)</span><!-- --></h1> <!--p class="lead my-3">Finde immer die günstigsten Angebote im Bereich Spirituosen. Täglich neue Schnäppchen.</p--> <p class="lead mb-0"><a href="/" class="text-white font-weight-bold">Zurück zur Übersicht...</a></p> </div> @@ -64,7 +64,7 @@ if ( !$data->count() ) { /* Keine Angebote */ ?> -<div class="alert alert-secondary" data-track-content data-content-name="{{ ucfirst($spirit_type) }}" data-content-piece="Keine Angebote" data-content-target=""> +<div class="alert alert-secondary" data-track-content data-content-name="{{ ucwords($spirit_type) }}" data-content-piece="Keine Angebote" data-content-target=""> <h4 class="alert-heading">Keine Angebote</h4> Momentan liegen keine {{ $title }} vor. Probieren Sie es später noch einmal. </div> @@ -89,7 +89,7 @@ foreach( $data as $offer) { <div class="card-header-dp-none"> <p><strong> <span style="visibility: hidden;"> - {{ ucfirst($offer->spirit_type) }} <span class="float-right">{{ $offer->shop }}</span> + {{ ucwords($offer->spirit_type) }} <span class="float-right">{{ $offer->shop }}</span> </span> </strong></p> </div> @@ -101,7 +101,7 @@ foreach( $data as $offer) { <div class="col-md-8 px-10"> <div class="card-header"> <p><strong> - <a style="color: inherit;" href="/angebote/search?q={{ ucfirst($offer->spirit_type) }}" title="Alle {{ ucfirst($offer->spirit_type) }} anzeigen">{{ ucfirst($offer->spirit_type) }}</a> <span class="float-right">{{ $offer->shop }}</span> + <a style="color: inherit;" href="/angebote/search?q={{ ucwords($offer->spirit_type) }}" title="Alle {{ ucwords($offer->spirit_type) }} anzeigen">{{ ucwords($offer->spirit_type) }}</a> <span class="float-right">{{ $offer->shop }}</span> </strong></p> </div> <div class="card-block card-body px-3"> @@ -165,7 +165,7 @@ foreach( $data as $offer) { <?php } /* -<div class="col-md-6 col-sm-12" id="{{ $offer->name }}" data-track-content data-content-name="{{ ucfirst($spirit_type) }}" data-content-piece="{{ $offer->name }}" data-content-target="{{ $offer->url }}"> +<div class="col-md-6 col-sm-12" id="{{ $offer->name }}" data-track-content data-content-name="{{ ucwords($spirit_type) }}" data-content-piece="{{ $offer->name }}" data-content-target="{{ $offer->url }}"> <div class="card flex-md-row mb-4 box-shadow h-md-250 h-sm-500"> <!-- >= md --> @@ -286,7 +286,7 @@ foreach( $data as $offer) { */ ?> - {{ $data->appends(Input::except('page'))->links() }} + {{ $data->appends(Input::except('page'))->links('paginate') }} <?php /* Ende Liste Angebote */ diff --git a/site/resources/views/fk-search.blade.php b/site/resources/views/fk-search.blade.php index 457fd5c..fcb2014 100644 --- a/site/resources/views/fk-search.blade.php +++ b/site/resources/views/fk-search.blade.php @@ -15,7 +15,7 @@ Finde den besten Deal <!-- Breadcrumb NavXT 6.2.1 --> <li class="home breadcrumb-item"><span property="itemListElement" typeof="ListItem"><a property="item" typeof="WebPage" title="Gehe zur Startseite: Fuselkönig.de" href="https://www.fuselkoenig.de" class="home"><span property="name">Startseite</span></a><meta property="position" content="1"></span></li> <li class="post post-angebote-archive breadcrumb-item"><span property="itemListElement" typeof="ListItem"><a property="item" typeof="WebPage" title="Schau dir Angebote an." href="/angebote/" class="post post-angebote-archive"><span property="name">Angebote</span></a><meta property="position" content="2"></span></li> -<li class="archive taxonomy type current-item breadcrumb-item active" aria-current="page"><span property="itemListElement" typeof="ListItem"><span property="name">Suche nach <strong>"{{ ucfirst($search_phrase) }}"</strong></span><meta property="position" content="3"></span></li> +<li class="archive taxonomy type current-item breadcrumb-item active" aria-current="page"><span property="itemListElement" typeof="ListItem"><span property="name">Suche nach <strong>"{{ ucwords($search_phrase) }}"</strong></span><meta property="position" content="3"></span></li> </ol> </nav> </div> @@ -30,7 +30,7 @@ if ( $data->count() ) { <div class="card-body"> <h1 class="card-title page-title">Suche</h1> <p> - Sie haben nach <strong>{{ ucfirst($search_phrase) }}</strong> gesucht ({{$count->count()}} Treffer) + Sie haben nach <strong>{{ ucwords($search_phrase) }}</strong> gesucht ({{$count->count()}} Treffer) </p> @include('snippets.fk-sortbuttons') <?php @@ -39,7 +39,7 @@ if ( $data->count() ) { <div class="alert alert-error" data-track-content data-content-name="Suche" data-content-piece="Keine Angebote" data-content-target=""> <h1 class="alert-heading">Keinen Treffer</h1> <p style="font-size: 17px;"> - Leider hat Ihre Suche nach <strong>{{ $search_phrase }}</strong> keine Ergebnisse ergeben. Bitte versuchen sie es erneut mit einem anderen Begriff. + Leider hat Ihre Suche nach <strong>{{ ucwords($search_phrase) }}</strong> keine Ergebnisse ergeben. Bitte versuchen sie es erneut mit einem anderen Begriff. </p> <form action="/angebote/search"> @@ -58,13 +58,13 @@ if ( $data->count() ) { </div> </header><!-- .page-header --> - {{ $data->appends(Input::except('page'))->links() }} + {{ $data->appends(Input::except('page'))->links('paginate') }} <?php /* <div class="jumbotron p-3 p-md-5 text-white rounded bg-dark bbg-white ttext-dark box-shadow"> <div class="col-md-6 px-0"> - <h1 class="display-4 font-italic">{{ ucfirst($spirit_type) }} <span class="text-mute ml-10">({{$count}} Angebote)</span><!-- --></h1> + <h1 class="display-4 font-italic">{{ ucwords($spirit_type) }} <span class="text-mute ml-10">({{$count}} Angebote)</span><!-- --></h1> <!--p class="lead my-3">Finde immer die günstigsten Angebote im Bereich Spirituosen. Täglich neue Schnäppchen.</p--> <p class="lead mb-0"><a href="/" class="text-white font-weight-bold">Zurück zur Übersicht...</a></p> </div> @@ -96,7 +96,7 @@ foreach( $data as $offer) { <div class="card-header-dp-none"> <p><strong> <span style="visibility: hidden;"> - {{ ucfirst($offer->spirit_type) }} <span class="float-right">{{ $offer->shop }}</span> + {{ ucwords($offer->spirit_type) }} <span class="float-right">{{ $offer->shop }}</span> </span> </strong></p> </div> @@ -108,7 +108,7 @@ foreach( $data as $offer) { <div class="col-md-8 px-10"> <div class="card-header"> <p><strong> - {{ ucfirst($offer->spirit_type) }} <span class="float-right">{{ $offer->shop }}</span> + {{ ucwords($offer->spirit_type) }} <span class="float-right">{{ $offer->shop }}</span> </strong></p> </div> <div class="card-block card-body px-3"> @@ -161,7 +161,7 @@ foreach( $data as $offer) { <?php } /* -<div class="col-md-6 col-sm-12" id="{{ $offer->name }}" data-track-content data-content-name="{{ ucfirst($spirit_type) }}" data-content-piece="{{ $offer->name }}" data-content-target="{{ $offer->url }}"> +<div class="col-md-6 col-sm-12" id="{{ $offer->name }}" data-track-content data-content-name="{{ ucwords($spirit_type) }}" data-content-piece="{{ $offer->name }}" data-content-target="{{ $offer->url }}"> <div class="card flex-md-row mb-4 box-shadow h-md-250 h-sm-500"> <!-- >= md --> @@ -282,7 +282,7 @@ foreach( $data as $offer) { */ ?> - {{ $data->appends(Input::except('page'))->links() }} + {{ $data->appends(Input::except('page'))->links('paginate') }} <?php /* Ende Liste Angebote */ diff --git a/site/resources/views/paginate.blade.php b/site/resources/views/paginate.blade.php new file mode 100644 index 0000000..1697097 --- /dev/null +++ b/site/resources/views/paginate.blade.php @@ -0,0 +1,36 @@ +@if ($paginator->hasPages()) + <ul class="pagination"> + {{-- Previous Page Link --}} + @if ($paginator->onFirstPage()) + <li class="page-item disabled"><span class="page-link">@lang('pagination.previous')</span></li> + @else + <li class="page-item"><a class="page-link" href="{{ $paginator->previousPageUrl() }}" rel="prev">@lang('pagination.previous')</a></li> + @endif + + {{-- Pagination Elements --}} + @foreach ($elements as $element) + {{-- "Three Dots" Separator --}} + @if (is_string($element)) + <li class="page-item disabled dp-md-none"><span class="page-link">{{ $element }}</span></li> + @endif + + {{-- Array Of Links --}} + @if (is_array($element)) + @foreach ($element as $page => $url) + @if ($page == $paginator->currentPage()) + <li class="page-item active dp-md-none"><span class="page-link">{{ $page }}</span></li> + @else + <li class="page-item dp-md-none"><a class="page-link" href="{{ $url }}">{{ $page }}</a></li> + @endif + @endforeach + @endif + @endforeach + + {{-- Next Page Link --}} + @if ($paginator->hasMorePages()) + <li class="page-item"><a class="page-link" href="{{ $paginator->nextPageUrl() }}" rel="next">@lang('pagination.next')</a></li> + @else + <li class="page-item disabled"><span class="page-link">@lang('pagination.next')</span></li> + @endif + </ul> +@endif |
