Skip to content

[8.x] Update Bootstrap pagination style #36467

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Illuminate/Foundation/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Application extends Container implements ApplicationContract, CachesConfig
*
* @var string
*/
const VERSION = '8.30.1';
const VERSION = '8.31.0';

/**
* The base path for the Laravel installation.
Expand Down
9 changes: 7 additions & 2 deletions src/Illuminate/Foundation/Console/PolicyMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,13 @@ protected function replaceModel($stub, $model)
array_keys($replace), array_values($replace), $stub
);

return str_replace(
"use {$namespacedModel};\nuse {$namespacedModel};", "use {$namespacedModel};", $stub
return preg_replace(
vsprintf('/use %s;[\r\n]+use %s;/', [
preg_quote($namespacedModel, '/'),
preg_quote($namespacedModel, '/'),
]),
"use {$namespacedModel};",
$stub
);
}

Expand Down
7 changes: 6 additions & 1 deletion src/Illuminate/Foundation/Console/VendorPublishCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Foundation\Events\VendorTagPublished;
use Illuminate\Support\Arr;
use Illuminate\Support\ServiceProvider;
use League\Flysystem\Adapter\Local as LocalAdapter;
Expand Down Expand Up @@ -159,14 +160,18 @@ protected function publishTag($tag)
{
$published = false;

foreach ($this->pathsToPublish($tag) as $from => $to) {
$pathsToPublish = $this->pathsToPublish($tag);

foreach ($pathsToPublish as $from => $to) {
$this->publishItem($from, $to);

$published = true;
}

if ($published === false) {
$this->error('Unable to locate publishable resources.');
} else {
$this->laravel['events']->dispatch(new VendorTagPublished($tag, $pathsToPublish));
}
}

Expand Down
33 changes: 33 additions & 0 deletions src/Illuminate/Foundation/Events/VendorTagPublished.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace Illuminate\Foundation\Events;

class VendorTagPublished
{
/**
* The vendor tag that was published.
*
* @var string
*/
public $tag;

/**
* The publishable paths registered by the tag.
*
* @var array
*/
public $paths;

/**
* Create a new event instance.
*
* @param string $tag
* @param array $paths
* @return void
*/
public function __construct($tag, $paths)
{
$this->tag = $tag;
$this->paths = $paths;
}
}
92 changes: 65 additions & 27 deletions src/Illuminate/Pagination/resources/views/bootstrap-4.blade.php
Original file line number Diff line number Diff line change
@@ -1,46 +1,84 @@
@if ($paginator->hasPages())
<nav>
<ul class="pagination">
<nav role="navigation" aria-label="{{ __('Pagination Navigation') }}" class="d-flex align-items-center justify-content-between">
<ul class="pagination d-flex justify-content-between flex-grow-1 d-sm-none">
{{-- Previous Page Link --}}
@if ($paginator->onFirstPage())
<li class="page-item disabled" aria-disabled="true" aria-label="@lang('pagination.previous')">
<span class="page-link" aria-hidden="true">&lsaquo;</span>
<li class="page-item disabled" aria-disabled="true">
<span class="page-link">@lang('pagination.previous')</span>
</li>
@else
<li class="page-item">
<a class="page-link" href="{{ $paginator->previousPageUrl() }}" rel="prev" aria-label="@lang('pagination.previous')">&lsaquo;</a>
<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" aria-disabled="true"><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" aria-current="page"><span class="page-link">{{ $page }}</span></li>
@else
<li class="page-item"><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" aria-label="@lang('pagination.next')">&rsaquo;</a>
<a class="page-link" href="{{ $paginator->nextPageUrl() }}" rel="next">@lang('pagination.next')</a>
</li>
@else
<li class="page-item disabled" aria-disabled="true" aria-label="@lang('pagination.next')">
<span class="page-link" aria-hidden="true">&rsaquo;</span>
<li class="page-item disabled" aria-disabled="true">
<span class="page-link">@lang('pagination.next')</span>
</li>
@endif
</ul>

<div class="d-none flex-sm-grow-1 d-flex align-items-sm-center justify-content-sm-between">
<div>
<p class="text-muted">
{!! __('Showing') !!}
<span class="font-weight-bolder">{{ $paginator->firstItem() }}</span>
{!! __('to') !!}
<span class="font-weight-bolder">{{ $paginator->lastItem() }}</span>
{!! __('of') !!}
<span class="font-weight-bolder">{{ $paginator->total() }}</span>
{!! __('results') !!}
</p>
</div>

<ul class="pagination">
{{-- Previous Page Link --}}
@if ($paginator->onFirstPage())
<li class="page-item disabled" aria-disabled="true" aria-label="@lang('pagination.previous')">
<span class="page-link" aria-hidden="true">&lsaquo;</span>
</li>
@else
<li class="page-item">
<a class="page-link" href="{{ $paginator->previousPageUrl() }}" rel="prev" aria-label="@lang('pagination.previous')">&lsaquo;</a>
</li>
@endif

{{-- Pagination Elements --}}
@foreach ($elements as $element)
{{-- "Three Dots" Separator --}}
@if (is_string($element))
<li class="page-item disabled" aria-disabled="true"><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" aria-current="page"><span class="page-link">{{ $page }}</span></li>
@else
<li class="page-item"><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" aria-label="@lang('pagination.next')">&rsaquo;</a>
</li>
@else
<li class="page-item disabled" aria-disabled="true" aria-label="@lang('pagination.next')">
<span class="page-link" aria-hidden="true">&rsaquo;</span>
</li>
@endif
</ul>
</div>
</nav>
@endif
11 changes: 11 additions & 0 deletions src/Illuminate/Support/Stringable.php
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,17 @@ public function matchAll($pattern)
return collect($matches[1] ?? $matches[0]);
}

/**
* Determine if the string matches the given pattern.
*
* @param string $pattern
* @return bool
*/
public function test($pattern)
{
return $this->match($pattern)->isNotEmpty();
}

/**
* Pad both sides of the string with another.
*
Expand Down
6 changes: 1 addition & 5 deletions src/Illuminate/Validation/Rules/DatabaseRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,7 @@ public function queryCallbacks()
protected function formatWheres()
{
return collect($this->wheres)->map(function ($where) {
if (is_bool($where['value'])) {
return $where['column'].','.($where['value'] ? 'true' : 'false');
} else {
return $where['column'].','.'"'.str_replace('"', '""', $where['value']).'"';
}
return $where['column'].','.'"'.str_replace('"', '""', $where['value']).'"';
})->implode(',');
}
}
8 changes: 8 additions & 0 deletions tests/Support/SupportStringableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ public function testMatch()
$this->assertTrue($stringable->matchAll('/nothing/')->isEmpty());
}

public function testTest()
{
$stringable = $this->stringable('foo bar');

$this->assertTrue($stringable->test('/bar/'));
$this->assertTrue($stringable->test('/foo (.*)/'));
}

public function testTrim()
{
$this->assertSame('foo', (string) $this->stringable(' foo ')->trim());
Expand Down