Skip to content

Commit

Permalink
Merge pull request #306 from ithsjeff/master
Browse files Browse the repository at this point in the history
Update Providers for Intervention Images v3
  • Loading branch information
mewebstudio authored Aug 16, 2024
2 parents 4ff3d6c + 5a49e45 commit e009e1e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/CaptchaServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
namespace Mews\Captcha;

use Illuminate\Routing\Router;
use Illuminate\Support\ServiceProvider;
use Illuminate\Validation\Factory;
use Intervention\Image\ImageManager;
use Illuminate\Support\ServiceProvider;
use Intervention\Image\Drivers\Gd\Driver as GdDriver;
use Intervention\Image\Drivers\Imagick\Driver as ImagickDriver;

/**
* Class CaptchaServiceProvider
Expand Down Expand Up @@ -71,6 +74,16 @@ public function register(): void
'captcha'
);

// Bind the ImageManager with an explicit driver
if (!$this->app->bound('Intervention\Image\ImageManager')) {
$this->app->singleton('Intervention\Image\ImageManager', function ($app) {
// Determine which driver to use, defaulting to 'gd'
$driver = config('captcha.driver', 'gd') === 'imagick' ? new ImagickDriver() : new GdDriver();

return new ImageManager($driver);
});
}

// Bind captcha
$this->app->bind('captcha', function ($app) {
return new Captcha(
Expand Down

0 comments on commit e009e1e

Please sign in to comment.