diff --git a/app/Domain/UiAvatar.php b/app/Domain/UiAvatar.php new file mode 100644 index 00000000..3bb094d9 --- /dev/null +++ b/app/Domain/UiAvatar.php @@ -0,0 +1,42 @@ +getUrl(); + } + + public function getUrl(): string + { + return "https://eu.ui-avatars.com/api/?" . http_build_query([ + "length" => $this->length, + "font-size" => $this->fontSize, + "size" => $this->size, + "rounded" => $this->rounded ? 1 : 0, + "uppercase" => $this->uppercase ? 1 : 0, + "background" => $this->background, + "color" => $this->color, + "bold" => $this->bold ? 1 : 0, + "region" => $this->region, + "name" => $this->name, + ]); + } +} diff --git a/app/Models/Profile.php b/app/Models/Profile.php index 6f34556e..191ae60e 100644 --- a/app/Models/Profile.php +++ b/app/Models/Profile.php @@ -9,7 +9,7 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Support\Carbon; -use Rackbeat\UIAvatars\HasAvatar; +use Toby\Domain\UiAvatar; use Toby\Enums\EmploymentForm; use Toby\Helpers\ColorGenerator; @@ -29,7 +29,6 @@ class Profile extends Model { use HasFactory; - use HasAvatar; protected $primaryKey = "user_id"; protected $guarded = []; @@ -51,9 +50,11 @@ public function user(): BelongsTo public function getAvatar(): string { - return $this->getAvatarGenerator() - ->backgroundColor(ColorGenerator::generate($this->full_name)) - ->image(); + $avatar = new UiAvatar(); + $avatar->background = ColorGenerator::generate($this->full_name); + $avatar->name = mb_substr($this->first_name, 0, 1) . mb_substr($this->last_name, 0, 1); + + return $avatar->getUrl(); } public function getFullNameAttribute(): string @@ -61,11 +62,6 @@ public function getFullNameAttribute(): string return "{$this->first_name} {$this->last_name}"; } - protected function getAvatarName(): string - { - return mb_substr($this->first_name, 0, 1) . mb_substr($this->last_name, 0, 1); - } - protected static function newFactory(): ProfileFactory { return ProfileFactory::new(); diff --git a/composer.json b/composer.json index 117fb1c2..130edc11 100644 --- a/composer.json +++ b/composer.json @@ -4,12 +4,6 @@ "description": "HR software you love to hate", "keywords": ["toby", "laravel", "hr"], "license": "MIT", - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/laravel-shift/laravel-ui-avatars.git" - } - ], "require": { "php": "^8.3", "ext-pdo": "*", @@ -27,7 +21,6 @@ "laravel/tinker": "^2.9", "maatwebsite/excel": "^3.1", "phpoffice/phpword": "1.1", - "rackbeat/laravel-ui-avatars": "dev-l11-compatibility", "sentry/sentry-laravel": "^4.2", "spatie/laravel-google-calendar": "3.8", "spatie/laravel-model-states": "^2.6", diff --git a/composer.lock b/composer.lock index 7f6ffd7d..4b676da0 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "029f9022264b42afb6f95a0331d26059", + "content-hash": "7028ee9595541a21e4c64d00b28f7c65", "packages": [ { "name": "azuyalabs/yasumi", @@ -1824,90 +1824,6 @@ ], "time": "2024-03-09T00:30:58+00:00" }, - { - "name": "intervention/image", - "version": "2.7.2", - "source": { - "type": "git", - "url": "https://github.com/Intervention/image.git", - "reference": "04be355f8d6734c826045d02a1079ad658322dad" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Intervention/image/zipball/04be355f8d6734c826045d02a1079ad658322dad", - "reference": "04be355f8d6734c826045d02a1079ad658322dad", - "shasum": "" - }, - "require": { - "ext-fileinfo": "*", - "guzzlehttp/psr7": "~1.1 || ^2.0", - "php": ">=5.4.0" - }, - "require-dev": { - "mockery/mockery": "~0.9.2", - "phpunit/phpunit": "^4.8 || ^5.7 || ^7.5.15" - }, - "suggest": { - "ext-gd": "to use GD library based image processing.", - "ext-imagick": "to use Imagick based image processing.", - "intervention/imagecache": "Caching extension for the Intervention Image library" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.4-dev" - }, - "laravel": { - "providers": [ - "Intervention\\Image\\ImageServiceProvider" - ], - "aliases": { - "Image": "Intervention\\Image\\Facades\\Image" - } - } - }, - "autoload": { - "psr-4": { - "Intervention\\Image\\": "src/Intervention/Image" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Oliver Vogel", - "email": "oliver@intervention.io", - "homepage": "https://intervention.io/" - } - ], - "description": "Image handling and manipulation library with support for Laravel integration", - "homepage": "http://image.intervention.io/", - "keywords": [ - "gd", - "image", - "imagick", - "laravel", - "thumbnail", - "watermark" - ], - "support": { - "issues": "https://github.com/Intervention/image/issues", - "source": "https://github.com/Intervention/image/tree/2.7.2" - }, - "funding": [ - { - "url": "https://paypal.me/interventionio", - "type": "custom" - }, - { - "url": "https://github.com/Intervention", - "type": "github" - } - ], - "time": "2022-05-21T17:30:32+00:00" - }, { "name": "jean85/pretty-package-versions", "version": "2.0.6", @@ -2685,167 +2601,6 @@ }, "time": "2024-01-04T16:10:04+00:00" }, - { - "name": "lasserafn/php-initial-avatar-generator", - "version": "4.3", - "source": { - "type": "git", - "url": "https://github.com/LasseRafn/php-initial-avatar-generator.git", - "reference": "ffe43d8df3f18646d7b23011272cce2d71400e1f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/LasseRafn/php-initial-avatar-generator/zipball/ffe43d8df3f18646d7b23011272cce2d71400e1f", - "reference": "ffe43d8df3f18646d7b23011272cce2d71400e1f", - "shasum": "" - }, - "require": { - "ext-json": "*", - "intervention/image": "^2.3", - "lasserafn/php-initials": "^3.0", - "lasserafn/php-string-script-language": "^0.4", - "meyfa/php-svg": "^0.9.0", - "overtrue/pinyin": "^4.0", - "php": "^7.0|^7.1|^7.2|^7.3|^7.4|^8.0|^8.1|^8.2" - }, - "require-dev": { - "phpunit/phpunit": "^8.5" - }, - "type": "library", - "autoload": { - "psr-4": { - "LasseRafn\\InitialAvatarGenerator\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Lasse Rafn", - "email": "lasserafn@gmail.com" - } - ], - "description": "A package to generate avatars with initials for PHP", - "keywords": [ - "Initials", - "avatar", - "image", - "svg" - ], - "support": { - "issues": "https://github.com/LasseRafn/php-initial-avatar-generator/issues", - "source": "https://github.com/LasseRafn/php-initial-avatar-generator/tree/4.3" - }, - "funding": [ - { - "url": "https://opencollective.com/ui-avatars", - "type": "open_collective" - } - ], - "time": "2023-07-26T19:17:56+00:00" - }, - { - "name": "lasserafn/php-initials", - "version": "3.1", - "source": { - "type": "git", - "url": "https://github.com/LasseRafn/php-initials.git", - "reference": "d287e1542687390eb68de779949bc0adc49e2d52" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/LasseRafn/php-initials/zipball/d287e1542687390eb68de779949bc0adc49e2d52", - "reference": "d287e1542687390eb68de779949bc0adc49e2d52", - "shasum": "" - }, - "require": { - "php": "^5.6|^7.0|^7.1|^8.0" - }, - "require-dev": { - "phpunit/phpunit": "^5.7", - "satooshi/php-coveralls": "^1.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "LasseRafn\\Initials\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Lasse Rafn", - "email": "lasserafn@gmail.com" - } - ], - "description": "A package to generate initials in PHP", - "keywords": [ - "Initials", - "php" - ], - "support": { - "issues": "https://github.com/LasseRafn/php-initials/issues", - "source": "https://github.com/LasseRafn/php-initials/tree/3.1" - }, - "time": "2020-12-24T12:25:51+00:00" - }, - { - "name": "lasserafn/php-string-script-language", - "version": "0.4", - "source": { - "type": "git", - "url": "https://github.com/LasseRafn/php-string-script-language.git", - "reference": "cab5612d4382067de855fcecc7c09108dca77fb5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/LasseRafn/php-string-script-language/zipball/cab5612d4382067de855fcecc7c09108dca77fb5", - "reference": "cab5612d4382067de855fcecc7c09108dca77fb5", - "shasum": "" - }, - "require": { - "php": "^5.6|^7.0|^7.1|^8.0|^8.1|^8.2" - }, - "require-dev": { - "doctrine/instantiator": "1.0.5", - "phpunit/phpunit": "^5.6", - "phpunit/phpunit-mock-objects": "3.2.4", - "satooshi/php-coveralls": "^1.0", - "sebastian/exporter": "^1.2" - }, - "type": "library", - "autoload": { - "psr-4": { - "LasseRafn\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Lasse Rafn", - "email": "lasserafn@gmail.com" - } - ], - "description": "Detect language/encoding of a string in PHP", - "keywords": [ - "language", - "php", - "string" - ], - "support": { - "issues": "https://github.com/LasseRafn/php-string-script-language/issues", - "source": "https://github.com/LasseRafn/php-string-script-language/tree/0.4" - }, - "time": "2023-07-26T07:23:39+00:00" - }, { "name": "league/commonmark", "version": "2.4.2", @@ -3651,56 +3406,6 @@ }, "time": "2023-05-10T11:58:31+00:00" }, - { - "name": "meyfa/php-svg", - "version": "v0.9.1", - "source": { - "type": "git", - "url": "https://github.com/meyfa/php-svg.git", - "reference": "34401edef1f724898f468f71b85505fbcc8351bb" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/meyfa/php-svg/zipball/34401edef1f724898f468f71b85505fbcc8351bb", - "reference": "34401edef1f724898f468f71b85505fbcc8351bb", - "shasum": "" - }, - "require": { - "ext-gd": "*", - "ext-simplexml": "*", - "php": ">=5.3.3" - }, - "require-dev": { - "meyfa/phpunit-assert-gd": "^1.1", - "phpunit/phpunit": "^4.8" - }, - "type": "library", - "autoload": { - "psr-4": { - "SVG\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabian Meyer", - "homepage": "http://meyfa.net" - } - ], - "description": "Read, edit, write, and render SVG files with PHP", - "homepage": "https://github.com/meyfa/php-svg", - "keywords": [ - "svg" - ], - "support": { - "issues": "https://github.com/meyfa/php-svg/issues", - "source": "https://github.com/meyfa/php-svg/tree/v0.9.1" - }, - "time": "2019-07-30T18:41:25+00:00" - }, { "name": "monolog/monolog", "version": "3.5.0", @@ -4280,79 +3985,6 @@ ], "time": "2023-11-13T09:31:12+00:00" }, - { - "name": "overtrue/pinyin", - "version": "4.1.0", - "source": { - "type": "git", - "url": "https://github.com/overtrue/pinyin.git", - "reference": "4d0fb4f27f0c79e81c9489e0c0ae4a4f8837eae7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/overtrue/pinyin/zipball/4d0fb4f27f0c79e81c9489e0c0ae4a4f8837eae7", - "reference": "4d0fb4f27f0c79e81c9489e0c0ae4a4f8837eae7", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "require-dev": { - "brainmaestro/composer-git-hooks": "^2.7", - "friendsofphp/php-cs-fixer": "^2.16", - "phpunit/phpunit": "~8.0" - }, - "type": "library", - "extra": { - "hooks": { - "pre-commit": [ - "composer test", - "composer fix-style" - ], - "pre-push": [ - "composer test", - "composer check-style" - ] - } - }, - "autoload": { - "files": [ - "src/const.php" - ], - "psr-4": { - "Overtrue\\Pinyin\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "overtrue", - "email": "anzhengchao@gmail.com", - "homepage": "http://github.com/overtrue" - } - ], - "description": "Chinese to pinyin translator.", - "homepage": "https://github.com/overtrue/pinyin", - "keywords": [ - "Chinese", - "Pinyin", - "cn2pinyin" - ], - "support": { - "issues": "https://github.com/overtrue/pinyin/issues", - "source": "https://github.com/overtrue/pinyin/tree/4.1.0" - }, - "funding": [ - { - "url": "https://github.com/overtrue", - "type": "github" - } - ], - "time": "2023-04-27T10:17:12+00:00" - }, { "name": "paragonie/constant_time_encoding", "version": "v2.6.3", @@ -5498,73 +5130,6 @@ }, "time": "2024-03-17T01:53:00+00:00" }, - { - "name": "rackbeat/laravel-ui-avatars", - "version": "dev-l11-compatibility", - "source": { - "type": "git", - "url": "https://github.com/laravel-shift/laravel-ui-avatars.git", - "reference": "14a410bb9bed2cd31ff3662d5cf74295e3f76c43" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/laravel-shift/laravel-ui-avatars/zipball/14a410bb9bed2cd31ff3662d5cf74295e3f76c43", - "reference": "14a410bb9bed2cd31ff3662d5cf74295e3f76c43", - "shasum": "" - }, - "require": { - "illuminate/support": "^7.0|^8.0|^9.0|^10.0|^11.0", - "lasserafn/php-initial-avatar-generator": "^4.0", - "php": ">=7.1" - }, - "require-dev": { - "phpunit/phpunit": "^7.0|^9.5.10|^10.5", - "satooshi/php-coveralls": "^1.0" - }, - "type": "library", - "extra": { - "laravel": { - "providers": [ - "Rackbeat\\UIAvatars\\UIAvatarsServiceProvider" - ] - } - }, - "autoload": { - "psr-4": { - "Rackbeat\\UIAvatars\\": "src/" - } - }, - "autoload-dev": { - "psr-4": { - "UIAvatars\\Tests\\": "tests/" - } - }, - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Lasse Rafn", - "email": "lasserafn@gmail.com" - }, - { - "name": "Rackbeat", - "email": "open-source@rackbeat.com" - } - ], - "description": "Official Laravel wrapper around ui-avatars.com and LasseRafn/php-initial-avatar-generator", - "keywords": [ - "avatars", - "initials", - "laravel", - "php", - "ui-avatars" - ], - "support": { - "source": "https://github.com/laravel-shift/laravel-ui-avatars/tree/l11-compatibility" - }, - "time": "2024-02-22T16:38:21+00:00" - }, { "name": "ralouphie/getallheaders", "version": "3.0.3", @@ -12096,9 +11661,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": { - "rackbeat/laravel-ui-avatars": 20 - }, + "stability-flags": [], "prefer-stable": true, "prefer-lowest": false, "platform": { diff --git a/config/ui-avatars.php b/config/ui-avatars.php deleted file mode 100644 index 10750655..00000000 --- a/config/ui-avatars.php +++ /dev/null @@ -1,23 +0,0 @@ - "api", - "default_region" => "eu", - "length" => 2, - "image_size" => 128, - "font_size" => 0.33, - "rounded" => true, - "smooth_rounding" => true, - "uppercase" => true, - "background_color" => "#A0A0A0", - "font_color" => "#FFFFFF", - "font_bold" => true, - "providers" => [ - "api" => ApiGenerator::class, - "local" => LocalGenerator::class, - ], -];