Skip to content

Fix Laravel 11 compability #99

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 3 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 composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"jaybizzle/crawler-detect": "^1.2",
"spatie/laravel-referer": "^1.6",
"torann/geoip": "^1.0|^3.0",
"nesbot/carbon": "^2.0"
"nesbot/carbon": "^2.0 || ^3.0"
},
"require-dev": {
"doctrine/dbal": "^2.6|^3.0",
Expand Down
4 changes: 2 additions & 2 deletions src/DataEngines/EloquentEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ public function addToFlatList(string $key, $value): bool
return (bool) $row->save();
}

public function valueList(string $key, int $limit = -1, bool $orderByAsc = false, bool $withValues = false): array
public function valueList(string $search, int $limit = -1, bool $orderByAsc = false, bool $withValues = false): array
{
$rows = $this->model->where('primary_key', $this->prefix.$key)
$rows = $this->model->where('primary_key', $this->prefix.$search)
->where(function($q) {
return $q->where('expired_at', '>', \Carbon\Carbon::now())->orWhereNull('expired_at');
})
Expand Down
4 changes: 2 additions & 2 deletions src/DataEngines/RedisEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ public function addToFlatList(string $key, $value): bool
return $this->connection->rpush($this->prefix . $key, $value) !== false;
}

public function valueList(string $key, int $limit = -1, bool $orderByAsc = false, bool $withValues = false): array
public function valueList(string $search, int $limit = -1, bool $orderByAsc = false, bool $withValues = false): array
{
$range = $orderByAsc ? 'zrange' : 'zrevrange';

return $this->connection->$range($this->prefix . $key, 0, $limit, $this->isPHPRedis ? $withValues : ['withscores' => $withValues]) ?: [];
return $this->connection->$range($this->prefix . $search, 0, $limit, $this->isPHPRedis ? $withValues : ['withscores' => $withValues]) ?: [];
}

public function exists(string $key): bool
Expand Down
2 changes: 1 addition & 1 deletion src/Traits/Periods.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected function newExpiration($period)
throw new Exception("Wrong period: `{$period}`! please update config/visits.php file.");
}

return $periodCarbon->diffInSeconds() + 1;
return (int) round(abs($periodCarbon->diffInSeconds())) + 1;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/PeriodsTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ public function day_test()


//time until redis delete periods
$this->assertEquals(1, now()->addSeconds(visits($post)->period('day')->timeLeft())->diffInDays($time));
$this->assertEquals(1, (int) now()->addSeconds(visits($post)->period('day')->timeLeft())->diffInDays($time, true));

//time until redis delete periods
$this->assertEquals(1, now()->addSeconds(visits('Awssat\Visits\Tests\Post')->period('day')->timeLeft())->diffInDays($time));
$this->assertEquals(1, (int) now()->addSeconds(visits('Awssat\Visits\Tests\Post')->period('day')->timeLeft())->diffInDays($time, true));
}

/** @test */
Expand Down