Add captcha image generation functionality.
This commit is contained in:
@@ -1,17 +1,40 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Captcha\Contracts\ImageBody;
|
||||
use App\Captcha\Contracts\ImageHead;
|
||||
use App\Captcha\Contracts\ImageLines;
|
||||
use App\Captcha\Contracts\ImageManager as ImageManagerContract;
|
||||
use App\Captcha\Images\Body;
|
||||
use App\Captcha\Images\Head;
|
||||
use App\Captcha\Images\ImageManager;
|
||||
use App\Captcha\Images\Lines;
|
||||
use App\Services\Api\V1\CaptchaService;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
final class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
//
|
||||
$this->app->bind(ImageManagerContract::class, function () {
|
||||
return new ImageManager(imageClassName: config('captcha.imageClass'));
|
||||
});
|
||||
$this->app->bind(ImageHead::class, Head::class);
|
||||
$this->app->bind(ImageBody::class, Body::class);
|
||||
$this->app->bind(ImageLines::class, Lines::class);
|
||||
|
||||
$this->app->bind(CaptchaService::class, function (Application $app) {
|
||||
return new CaptchaService(
|
||||
config: config('captcha', []),
|
||||
imageHead: $app->make(ImageHead::class),
|
||||
imageBody: $app->make(ImageBody::class)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user