Skip to content

Commit

Permalink
Merge pull request #7 from deimarhc/GM-117
Browse files Browse the repository at this point in the history
Laravel 10 support
  • Loading branch information
damiankloip committed Sep 15, 2023
2 parents 70af5c7 + 5329f7a commit 0af709d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
"type": "library",
"require": {
"php": "^8.0",
"laravel/framework": "^9.0"
"laravel/framework": "^9.0|^10.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"orchestra/testbench": "^5.0|^6.0|^7.0",
"orchestra/testbench": "^5.0|^6.0|^7.0|^8.0",
"mockery/mockery": "^1.1",
"squizlabs/php_codesniffer": "^3.3",
"php-coveralls/php-coveralls": "^2.1",
Expand Down
4 changes: 2 additions & 2 deletions src/Http/Middleware/CheckDbMaintenance.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace FriendsOfCat\LaravelDbMaintenance\Http\Middleware;

use FriendsOfCat\LaravelDbMaintenance\Maintenance;
use Illuminate\Foundation\Http\Exceptions\MaintenanceModeException;
use Illuminate\Http\Request;
use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException;

class CheckDbMaintenance
{
Expand Down Expand Up @@ -35,7 +35,7 @@ public function handle(Request $request, $next)
{
if ($this->maintenance->isDown()) {
$latest = $this->maintenance->getLatest();
throw new MaintenanceModeException($latest->created_at, $latest->retry_after, $latest->message);
throw new ServiceUnavailableHttpException($latest->retry_after, $latest->message);
}

return $next($request);
Expand Down
34 changes: 17 additions & 17 deletions src/Maintenance.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
class Maintenance
{

/**
* @var string
*/
/**
* @var string
*/
protected $tableName = 'maintenance';

/**
Expand Down Expand Up @@ -55,11 +55,11 @@ public function up()
$max = $this->getTableBuilder()->max('id');

return (bool) $this->getTableBuilder()
->where('id', $max)
->update([
'status' => false,
'updated_at' => $this->nowTimestamp(),
]);
->where('id', $max)
->update([
'status' => false,
'updated_at' => $this->nowTimestamp(),
]);
}

/**
Expand Down Expand Up @@ -87,12 +87,12 @@ public function down($message = '', $retry_after = 60)
$now = $this->nowTimestamp();

return $this->getTableBuilder()->insert([
'created_at' => $now,
'updated_at' => $now,
'status' => true,
'retry_after' => $retry_after,
'message' => $message,
]);
'created_at' => $now,
'updated_at' => $now,
'status' => true,
'retry_after' => $retry_after,
'message' => $message,
]);
}

/**
Expand All @@ -110,9 +110,9 @@ public function getLatest()
{
if (!isset($this->latest)) {
$this->latest = $this->getTableBuilder()
->orderBy('id', 'desc')
->limit(1)
->first();
->orderBy('id', 'desc')
->limit(1)
->first();

if (is_null($this->latest)) {
$this->latest = $this->defaultLatest();
Expand Down
4 changes: 2 additions & 2 deletions tests/src/Http/Middleware/CheckDbMaintenanceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
use Carbon\Carbon;
use FriendsOfCat\LaravelDbMaintenance\Http\Middleware\CheckDbMaintenance;
use FriendsOfCat\LaravelDbMaintenance\Maintenance;
use Illuminate\Foundation\Http\Exceptions\MaintenanceModeException;
use Illuminate\Http\Request;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException;

/**
* @coversDefaultClass \FriendsOfCat\LaravelDbMaintenance\Http\Middleware\CheckDbMaintenance
Expand Down Expand Up @@ -43,7 +43,7 @@ public function testHandleWhenUp()
*/
public function testHandleWhenDown()
{
$this->expectException(MaintenanceModeException::class);
$this->expectException(ServiceUnavailableHttpException::class);

Carbon::setTestNow();

Expand Down

0 comments on commit 0af709d

Please sign in to comment.