Skip to content

Commit dca5a41

Browse files
update
1 parent e4b7722 commit dca5a41

File tree

9 files changed

+60
-14
lines changed

9 files changed

+60
-14
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ $another->logout(); // clears in-memory and session
695695
| allow | `true` \| `false` | Default `false` Setting to true will allow the system use this settings across app|
696696
| class | string | Css `selector` For pagination ul tag in the browser |
697697
| span | string | Default `.page-span` Css `selector` For pagination Showing Span tags in the browser |
698-
| view | `bootstrap` \| `simple` \| `cursor` | Default `simple` - For pagination design |
698+
| view | `bootstrap` \| `cursor` \| `loading` | Default `simple` - For pagination design |
699699
| first | string | Change the letter `First` |
700700
| last | string | Change the letter `Last` |
701701
| next | string | Change the letter `Next` |

src/AutoLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public static function configPagination(?array $options = [])
120120
$default['view'] = in_array($default['view'], $getViews)
121121
? $options['view']
122122
: $text['view'];
123-
123+
124124
/*
125125
|--------------------------------------------------------------------------
126126
| Adding Pagination Configuration into Constant

src/Dummy/dummyInit.dum

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ $db = DB::connection();
5555
| allow | true\false | Default `false` Setting to true will allow the system use this settings across app
5656
| class | string | Css `selector` For pagination ul tag in the browser
5757
| span | string | Css `selector` For pagination Showing Span tags in the browser
58-
| view | bootstrap\simple\cursor | Default `simple` - For pagination design
58+
| view | bootstrap\cursor\loading | Default `simple` - For pagination design
5959
| first | string | Change the letter of `First`
6060
| last | string | Change the letter of `Last`
6161
| next | string | Change the letter of `Next`

src/Schema/Builder.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,9 +1445,9 @@ public function paginate($perPage = 15, $pageParam = 'page')
14451445
$results = $paginator->getPagination($totalCount, $perPage, $this);
14461446

14471447

1448-
dd(
1449-
$results
1450-
);
1448+
// dd(
1449+
// $results
1450+
// );
14511451

14521452
return new Collection($results['data'], $results['builder']);
14531453
}

src/Schema/Pagination/Paginator.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function configPagination(?array $options = [])
112112
: $this->asset->texts('view');
113113
}
114114

115-
// helps to use one simple settings for all pagination within applicaiton life circle
115+
// helps to use one settings for all pagination within applicaiton life circle
116116
$this->use_global = $this->pagination_settings['allow'];
117117

118118
return $this;
@@ -218,10 +218,14 @@ public function showing(?array $options = [])
218218
private function paginationViews(?array $options = [])
219219
{
220220
// if bootstrap view
221-
if(Str::lower($options['view']) == $this->asset->views('bootstrap')){
221+
$view = Str::lower($options['view']);
222+
223+
if($view == $this->asset->views('bootstrap')){
222224
$this->pagination_css = $this->asset->views('bootstrap');
223-
} elseif(Str::lower($options['view']) == $this->asset->views('simple')){
225+
} elseif($view == $this->asset->views('simple')){
224226
$this->pagination_css = $this->asset->views('simple');
227+
} elseif($view == $this->asset->views('loading')){
228+
$this->pagination_css = $this->asset->views('loading');
225229
} else{
226230
$this->pagination_css = $this->asset->views('cursor');
227231
}

src/Schema/Pagination/PaginatorAsset.php

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public static function views($mode = null)
4545
'bootstrap' => 'bootstrap',
4646
'simple' => 'simple',
4747
'cursor' => 'cursor',
48+
'loading' => 'loading',
4849
];
4950

5051
return $data[$mode] ?? $data;
@@ -80,15 +81,21 @@ public static function getStyles(?string $mode = 'simple')
8081
return self::getSimpleCss();
8182
} elseif($mode == self::views('bootstrap')){
8283
return self::getBootstrapCss();
83-
}
84-
return self::getCursorCss();
84+
} elseif($mode == self::views('loading')){
85+
return self::getLoadingCss();
86+
} else {
87+
return self::getCursorCss();
88+
}
8589
} elseif(STYLE_EXISTS != $mode){
8690
if($mode == self::views('simple')){
8791
return self::getSimpleCss();
8892
} elseif($mode == self::views('bootstrap')){
8993
return self::getBootstrapCss();
90-
}
91-
return self::getCursorCss();
94+
} elseif($mode == self::views('loading')){
95+
return self::getLoadingCss();
96+
} else {
97+
return self::getCursorCss();
98+
}
9299
}
93100
}
94101

@@ -128,6 +135,18 @@ public static function getCursorCss()
128135
</style>");
129136
}
130137

138+
/**
139+
* Return loading pagination css style
140+
*
141+
* @return string
142+
*/
143+
public static function getLoadingCss()
144+
{
145+
return self::compressCss("<style>
146+
.load-more-container{text-align: center;margin: 20px 0;}.load-more-btn{background-color: #1098ad;color: #fff;border: none;padding: 10px 20px;border-radius: 5px;cursor: pointer;font-weight: 600;}.load-more-btn:hover{background-color: #0e7a8a;}
147+
</style>");
148+
}
149+
131150
/**
132151
* Compresses CSS by removing comments, compressing spaces, and trimming the resulting string.
133152
*
@@ -157,3 +176,5 @@ private static function compressCss(string $string)
157176
return trim($string);
158177
}
159178
}
179+
180+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<div class="load-more-container" style="text-align: center; margin: 20px 0;">
2+
<?php
3+
$page = $this->pagination->page;
4+
$totalPages = $this->pagination->pageCount;
5+
$isLast = $page >= $totalPages;
6+
$nextPage = $page + 1;
7+
$nextUrl = $this->pagination->createUrl($nextPage);
8+
?>
9+
<?php if (!$isLast): ?>
10+
<button type="button" class="load-more-btn" data-page="<?php echo $nextPage; ?>" data-url="<?php echo $nextUrl; ?>" style="padding: 10px 20px; background-color: #007bff; color: white; border: none; border-radius: 5px; cursor: pointer;">
11+
Load More
12+
</button>
13+
<?php else: ?>
14+
<p>No more content to load.</p>
15+
<?php endif; ?>
16+
</div>

src/helpers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ function schema()
150150
* - allow | true\false | Default `false` Setting to true will allow the system use this settings across app
151151
* - class | string | Css `selector` For pagination ul tag in the browser
152152
* - span | string | Css `selector` For pagination Showing Span tags in the browser
153-
* - view | bootstrap\simple | Default `simple` - For pagination design
153+
* - view | bootstrap\cursor\loading | Default `simple` - For pagination design
154154
* - first | string | Change the letter of `First`
155155
* - last | string | Change the letter of `Last`
156156
* - next | string | Change the letter of `Next`

tests/testLoop.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77

88
$database = DB::connection();
99

10+
config_pagination([
11+
'allow' => true,
12+
'view' => 'loading' //bootstrap|loading|simple/cursor[default]
13+
]);
14+
1015
// dd(
1116
// DB::table('wallet'),
1217
// $database->table('country'),

0 commit comments

Comments
 (0)