Skip to content
Merged
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
1 change: 0 additions & 1 deletion resources/views/bootstrap-5/per-page.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@php
$amounts = [10 => 10, 20 => 20, 50 => 50, 100 => 100, 500 => 500];
$selected_per_page = $per_page ?? request('per_page', get_setting('per_page'));

if (! in_array($selected_per_page, $amounts)) {
Expand Down
1 change: 0 additions & 1 deletion resources/views/material-admin-26/per-page.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@php
$amounts = [10 => 10, 20 => 20, 50 => 50, 100 => 100, 500 => 500];
$selected_per_page = $per_page ?? request('per_page', get_setting('per_page'));

if (! in_array($selected_per_page, $amounts)) {
Expand Down
7 changes: 6 additions & 1 deletion src/Views/Components/PerPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,19 @@ class PerPage extends Component
{
protected string $view = 'per-page';

public array $amounts;

/**
* Create a new component instance.
*
* @return void
*/
public function __construct(
array $amounts = [10 => 10, 20 => 20, 50 => 50, 100 => 100, 500 => 500],
string $framework = '',
) {
)
{
$this->amounts = $amounts;
parent::__construct($framework);
}

Expand Down
62 changes: 62 additions & 0 deletions tests/Feature/PerPageTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

namespace Javaabu\Forms\Tests\Feature;

use Javaabu\Forms\Tests\TestCase;

class PerPageTest extends TestCase
{
/** @test */
public function it_can_see_the_default_per_page_options_bs5()
{
$this->setFrameworkBootstrap5();

$this->registerTestRoute('per-page')
->visit('/per-page')
->see('10')
->see('20')
->see('50')
->see('100')
->see('500');
}

/** @test */
public function it_can_see_the_custom_per_page_options_bs5()
{
$this->setFrameworkBootstrap5();

$this->withoutExceptionHandling();
$this->registerTestRoute('per-page-custom')
->visit('/per-page-custom')
->see('11')
->see('22')
->see('55');
}

/** @test */
public function it_can_see_the_default_per_page_options_material_admin_26()
{
$this->setFrameworkMaterialAdmin26();

$this->registerTestRoute('per-page')
->visit('/per-page')
->see('10')
->see('20')
->see('50')
->see('100')
->see('500');
}

/** @test */
public function it_can_see_the_custom_per_page_options_material_admin_26()
{
$this->setFrameworkMaterialAdmin26();

$this->withoutExceptionHandling();
$this->registerTestRoute('per-page-custom')
->visit('/per-page-custom')
->see('11')
->see('22')
->see('55');
}
}
1 change: 1 addition & 0 deletions tests/TestSupport/views/per-page-custom.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<x-forms::per-page :amounts="[11 => 11, 22 => 22, 55 => 55]"/>
1 change: 1 addition & 0 deletions tests/TestSupport/views/per-page.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<x-forms::per-page />