mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-02 20:25:28 +00:00
Fix various code.
This commit is contained in:
@@ -36,6 +36,8 @@ use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\Route as RouteFacade;
|
||||
use Hash;
|
||||
|
||||
use function Safe\parse_url;
|
||||
|
||||
/**
|
||||
* Trait RequestInformation
|
||||
*/
|
||||
@@ -47,7 +49,7 @@ trait RequestInformation
|
||||
final protected function getDomain(): string // get request info
|
||||
{
|
||||
$url = url()->to('/');
|
||||
$parts = \Safe\parse_url($url);
|
||||
$parts = parse_url($url);
|
||||
|
||||
return $parts['host'] ?? '';
|
||||
}
|
||||
@@ -95,7 +97,7 @@ trait RequestInformation
|
||||
$shownDemo = app('preferences')->get($key, false)->data;
|
||||
}
|
||||
if (!is_bool($shownDemo)) {
|
||||
$shownDemo = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
return $shownDemo;
|
||||
@@ -123,20 +125,19 @@ trait RequestInformation
|
||||
final protected function notInSessionRange(Carbon $date): bool // Validate a preference
|
||||
{
|
||||
/** @var Carbon $start */
|
||||
$start = session('start', today(config('app.timezone'))->startOfMonth());
|
||||
$start = session('start', today(config('app.timezone'))->startOfMonth());
|
||||
|
||||
/** @var Carbon $end */
|
||||
$end = session('end', today(config('app.timezone'))->endOfMonth());
|
||||
$result = false;
|
||||
$end = session('end', today(config('app.timezone'))->endOfMonth());
|
||||
if ($start->greaterThanOrEqualTo($date) && $end->greaterThanOrEqualTo($date)) {
|
||||
$result = true;
|
||||
return true;
|
||||
}
|
||||
// start and end in the past? use $end
|
||||
if ($start->lessThanOrEqualTo($date) && $end->lessThanOrEqualTo($date)) {
|
||||
$result = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
return $result;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -147,14 +148,14 @@ trait RequestInformation
|
||||
$attributes['location'] ??= '';
|
||||
$attributes['accounts'] = AccountList::routeBinder($attributes['accounts'] ?? '', new Route('get', '', []));
|
||||
$date = Carbon::createFromFormat('Ymd', $attributes['startDate']);
|
||||
if (null === $date) {
|
||||
if (!$date instanceof Carbon) {
|
||||
$date = today(config('app.timezone'));
|
||||
}
|
||||
$date->startOfMonth();
|
||||
$attributes['startDate'] = $date;
|
||||
|
||||
$date2 = Carbon::createFromFormat('Ymd', $attributes['endDate']);
|
||||
if (null === $date2) {
|
||||
if (!$date2 instanceof Carbon) {
|
||||
$date2 = today(config('app.timezone'));
|
||||
}
|
||||
$date2->endOfDay();
|
||||
|
||||
Reference in New Issue
Block a user