Skip to content

Commit

Permalink
laravel 11
Browse files Browse the repository at this point in the history
  • Loading branch information
RTippin committed May 23, 2024
1 parent 90930b0 commit 858ae14
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 29 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
| `8.x` | `^7.4` `^8.0` `^8.1` | `<= 1.19.1` |
| `9.x` | `^8.0.2` `^8.1` | `>= 1.20.0` |
| `10.x` | `^8.1` `^8.2` `^8.3` | `>= 1.22.0` |
| `11.x` | `^8.2` `^8.3` | `>= 1.23.0` |

- Route model binding enabled in your API / WEB middleware groups.

Expand Down
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@
"php": "^8.1|^8.2|^8.3",
"ext-json": "*",
"intervention/image": "^2.5",
"intervention/imagecache": "^2.5",
"joypixels/emoji-toolkit": "^6.0",
"laravel/framework": "^10.0"
"laravel/framework": "^11.0"
},
"require-dev": {
"phpunit/phpunit": "^10.0",
"orchestra/testbench": "^8.0"
"orchestra/testbench": "^9.0"
},
"autoload": {
"files": [
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
<env name="APP_ENV" value="self-testing"/>
<env name="APP_KEY" value="base64:yk+bUVuZa1p86Dqjk9OjVK2R1pm6XHxC6xEKFq8utH0="/>
<env name="APP_URL" value="http://messenger.test"/>
<env name="CACHE_DRIVER" value="file"/>
<env name="CACHE_DRIVER" value="array"/>
</php>
</phpunit>
7 changes: 6 additions & 1 deletion src/Actions/Invites/StoreInvite.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use RTippin\Messenger\Messenger;
use RTippin\Messenger\Models\Invite;
use RTippin\Messenger\Models\Thread;
use Throwable;

class StoreInvite extends InviteAction
{
Expand Down Expand Up @@ -93,7 +94,11 @@ private function setExpiresAt(?string $expires): ?Carbon
return null;
}

return Carbon::parse($expires);
try {
return Carbon::parse($expires);
} catch (Throwable) {
return null;
}
}

/**
Expand Down
31 changes: 14 additions & 17 deletions src/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace RTippin\Messenger\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Str;
use RTippin\Messenger\Messenger;

Expand Down Expand Up @@ -78,25 +79,21 @@ private function registerMessengerServiceProvider(): void
{
$namespace = Str::replaceLast('\\', '', $this->laravel->getNamespace());

$appConfig = file_get_contents(config_path('app.php'));
if (file_exists($this->laravel->bootstrapPath('providers.php'))) {
ServiceProvider::addProviderToBootstrapFile("{$namespace}\\Providers\\MessengerServiceProvider");
} else {
$appConfig = file_get_contents(config_path('app.php'));

if (Str::contains($appConfig, $namespace.'\\Providers\\MessengerServiceProvider::class')) {
return;
}

$lineEndingCount = [
"\r\n" => substr_count($appConfig, "\r\n"),
"\r" => substr_count($appConfig, "\r"),
"\n" => substr_count($appConfig, "\n"),
];
if (Str::contains($appConfig, $namespace.'\\Providers\\MessengerServiceProvider::class')) {
return;
}

$eol = array_keys($lineEndingCount, max($lineEndingCount))[0];

file_put_contents(config_path('app.php'), str_replace(
"{$namespace}\\Providers\EventServiceProvider::class,".$eol,
"{$namespace}\\Providers\EventServiceProvider::class,".$eol." {$namespace}\Providers\MessengerServiceProvider::class,".$eol,
$appConfig
));
file_put_contents(config_path('app.php'), str_replace(
"{$namespace}\\Providers\EventServiceProvider::class,".PHP_EOL,
"{$namespace}\\Providers\EventServiceProvider::class,".PHP_EOL." {$namespace}\Providers\MessengerServiceProvider::class,".PHP_EOL,
$appConfig
));
}

file_put_contents(app_path('Providers/MessengerServiceProvider.php'), str_replace(
"namespace App\Providers;",
Expand Down
10 changes: 3 additions & 7 deletions src/Services/ImageRenderService.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,13 +301,9 @@ private function renderImageSize(string $file, string $size)
? $width = null
: $height = null;

$resize = $this->imageManager->cache(function ($image) use ($file, $width, $height) {
return $image->make($file)->resize($width, $height, function ($constraint) {
$constraint->aspectRatio();
});
}, 120);

return $this->imageManager->make($resize)->response();
return $this->imageManager->make($file)->resize($width, $height, function ($constraint) {
$constraint->aspectRatio();
})->response();
} catch (Exception $e) {
report($e);
}
Expand Down
4 changes: 4 additions & 0 deletions tests/Http/CallChannelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ protected function getEnvironmentSetUp($app): void

// Need to set a driver other than null
// for broadcast routes to be utilized
$app->get('config')->set('broadcasting.connections.redis', [
'driver' => 'redis',
'connection' => 'default',
]);
$app->get('config')->set('broadcasting.default', 'redis');
}

Expand Down
4 changes: 4 additions & 0 deletions tests/Http/ProviderChannelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ protected function getEnvironmentSetUp($app): void

// Need to set a driver other than null
// for broadcast routes to be utilized
$app->get('config')->set('broadcasting.connections.redis', [
'driver' => 'redis',
'connection' => 'default',
]);
$app->get('config')->set('broadcasting.default', 'redis');
}

Expand Down
4 changes: 4 additions & 0 deletions tests/Http/ThreadChannelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ protected function getEnvironmentSetUp($app): void

// Need to set a driver other than null
// for broadcast routes to be utilized
$app->get('config')->set('broadcasting.connections.redis', [
'driver' => 'redis',
'connection' => 'default',
]);
$app->get('config')->set('broadcasting.default', 'redis');
}

Expand Down

0 comments on commit 858ae14

Please sign in to comment.