Skip to content

Commit 90cec91

Browse files
committed
Progress on v4
1 parent 06fa70a commit 90cec91

File tree

7 files changed

+37
-40
lines changed

7 files changed

+37
-40
lines changed

src/Argon/README.md

-3
This file was deleted.

src/Auth/Models/User.php

+8
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,14 @@ public function getAuthIdentifierName()
670670
return $this->getKeyName();
671671
}
672672

673+
/**
674+
* getAuthPasswordName of the password attribute for the user.
675+
*/
676+
public function getAuthPasswordName()
677+
{
678+
return 'password';
679+
}
680+
673681
/**
674682
* getAuthIdentifier gets the unique identifier for the user
675683
* @return mixed

src/Database/Builder.php

+16-21
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ protected function searchWhereInternal($term, $columns, $mode, $boolean)
164164
* @param int $page
165165
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
166166
*/
167-
public function paginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null)
167+
public function paginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null, $total = null)
168168
{
169169
// Legacy signature support
170170
// paginate($perPage, $page, $columns, $pageName)
@@ -178,18 +178,17 @@ public function paginate($perPage = null, $columns = ['*'], $pageName = 'page',
178178
$page = is_array($_currentPage) ? null : $_currentPage;
179179
}
180180

181-
if (!$page) {
182-
$page = Paginator::resolveCurrentPage($pageName);
183-
}
181+
$page = $page ?: Paginator::resolveCurrentPage($pageName);
184182

185-
if (!$perPage) {
186-
$perPage = $this->model->getPerPage();
187-
}
183+
$total = value($total) ?? $this->toBase()->getCountForPagination();
188184

189-
$total = $this->toBase()->getCountForPagination();
190-
$this->forPage((int) $page, (int) $perPage);
185+
$perPage = value($perPage, $total) ?: $this->model->getPerPage();
191186

192-
return $this->paginator($this->get($columns), $total, $perPage, $page, [
187+
$results = $total
188+
? $this->forPage($page, $perPage)->get($columns)
189+
: $this->model->newCollection();
190+
191+
return $this->paginator($results, $total, $perPage, $page, [
193192
'path' => Paginator::resolveCurrentPath(),
194193
'pageName' => $pageName
195194
]);
@@ -204,31 +203,27 @@ public function paginate($perPage = null, $columns = ['*'], $pageName = 'page',
204203
* @param int $currentPage
205204
* @return \Illuminate\Contracts\Pagination\Paginator
206205
*/
207-
public function simplePaginate($perPage = null, $columns = ['*'], $pageName = 'page', $currentPage = null)
206+
public function simplePaginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null)
208207
{
209208
// Legacy signature support
210209
// paginate($perPage, $currentPage, $columns, $pageName)
211210
if (!is_array($columns)) {
212211
$_currentPage = $columns;
213212
$_columns = $pageName;
214-
$_pageName = $currentPage;
213+
$_pageName = $page;
215214

216215
$columns = is_array($_columns) ? $_columns : ['*'];
217216
$pageName = $_pageName !== null ? $_pageName : 'page';
218-
$currentPage = is_array($_currentPage) ? null : $_currentPage;
217+
$page = is_array($_currentPage) ? null : $_currentPage;
219218
}
220219

221-
if (!$currentPage) {
222-
$currentPage = Paginator::resolveCurrentPage($pageName);
223-
}
220+
$page = $page ?: Paginator::resolveCurrentPage($pageName);
224221

225-
if (!$perPage) {
226-
$perPage = $this->model->getPerPage();
227-
}
222+
$perPage = $perPage ?: $this->model->getPerPage();
228223

229-
$this->skip(($currentPage - 1) * $perPage)->take($perPage + 1);
224+
$this->skip(($page - 1) * $perPage)->take($perPage + 1);
230225

231-
return $this->simplePaginator($this->get($columns), $perPage, $currentPage, [
226+
return $this->simplePaginator($this->get($columns), $perPage, $page, [
232227
'path' => Paginator::resolveCurrentPath(),
233228
'pageName' => $pageName
234229
]);

src/Database/DatabaseServiceProvider.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function register()
2020
Model::flushEventListeners();
2121

2222
$this->registerConnectionServices();
23-
$this->registerEloquentFactory();
23+
$this->registerFakerGenerator();
2424
$this->registerQueueableEntityResolver();
2525
}
2626

src/Argon/ArgonServiceProvider.php src/Foundation/Providers/DateServiceProvider.php

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php namespace October\Rain\Argon;
1+
<?php namespace October\Rain\Foundation\Providers;
22

33
use Carbon\Carbon;
44
use Carbon\CarbonImmutable;
@@ -8,19 +8,16 @@
88
use October\Rain\Support\ServiceProvider;
99

1010
/**
11-
* ArgonServiceProvider
12-
*
13-
* @package october\argon
14-
* @author Alexey Bobkov, Samuel Georges
11+
* DateServiceProvider
1512
*/
16-
class ArgonServiceProvider extends ServiceProvider
13+
class DateServiceProvider extends ServiceProvider
1714
{
1815
/**
1916
* register the service provider.
2017
*/
2118
public function register()
2219
{
23-
DateFactory::useClass(\October\Rain\Argon\Argon::class);
20+
DateFactory::useClass(\October\Rain\Support\Date::class);
2421
}
2522

2623
/**

src/Argon/Argon.php src/Support/Date.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
<?php namespace October\Rain\Argon;
1+
<?php namespace October\Rain\Support;
22

33
use Carbon\Carbon as DateBase;
44

55
/**
6-
* Argon is an umbrella class for Carbon that automatically applies localizations
6+
* Date is an umbrella class for Carbon that automatically applies localizations
77
*
8-
* @package october\argon
8+
* @package october\support
99
* @author Alexey Bobkov, Samuel Georges
1010
*/
11-
class Argon extends DateBase
11+
class Date extends DateBase
1212
{
1313
/**
1414
* format
1515
*/
16-
public function format($format)
16+
public function format(string $format): string
1717
{
1818
return parent::translatedFormat($format);
1919
}
2020

2121
/**
2222
* createFromFormat
2323
*/
24-
public static function createFromFormat($format, $time, $timezone = null)
24+
public static function createFromFormat($format, $time, $timezone = null): ?DateBase
2525
{
2626
if (is_string($time)) {
2727
$time = static::translateTimeString($time, static::getLocale(), 'en');
@@ -33,7 +33,7 @@ public static function createFromFormat($format, $time, $timezone = null)
3333
/**
3434
* parse
3535
*/
36-
public static function parse($time = null, $timezone = null)
36+
public static function parse($time = null, $timezone = null): static
3737
{
3838
if (is_string($time)) {
3939
$time = static::translateTimeString($time, static::getLocale(), 'en');

src/Support/DefaultProviders.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function __construct(?array $providers = null)
2020
\October\Rain\Halcyon\HalcyonServiceProvider::class,
2121
\October\Rain\Filesystem\FilesystemServiceProvider::class,
2222
\October\Rain\Html\UrlServiceProvider::class,
23-
\October\Rain\Argon\ArgonServiceProvider::class,
23+
\October\Rain\Foundation\Providers\DateServiceProvider::class,
2424

2525
// October Providers (Deferred)
2626
\October\Rain\Mail\MailServiceProvider::class,

0 commit comments

Comments
 (0)