Skip to content

Commit

Permalink
Add discord socialite provider support
Browse files Browse the repository at this point in the history
  • Loading branch information
ABSAhmad committed Apr 19, 2024
1 parent 2320fe9 commit e24a6ba
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
"orchestra/testbench": "^9.0",
"phpunit/phpunit": "^10.5"
},
"suggest": {
"socialiteproviders/discord": "To use the discord socialite provider"
},
"autoload": {
"psr-4": {
"Wallo\\FilamentCompanies\\": "src/"
Expand Down
13 changes: 13 additions & 0 deletions resources/views/components/socialite-icons/discord.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 231" aria-hidden="true">
<defs>
<linearGradient id="a" x1="108.63338%" x2="46.9265964%" y1="13.818022%" y2="78.7761408%">
<stop offset="18%" stop-color="#0052CC" />
<stop offset="100%" stop-color="#2684FF" />
</linearGradient>
</defs>
<g fill="none">
<path d="M101.272088 152.561281h53.448624l12.901393-75.3195555H87.0600784z" />
<path fill="#2684FF" d="M8.30813067.0006835C5.88502974-.03056855 3.57212663 1.01125669 1.98985644 2.8466901.40758624 4.68212353-.282086 7.12328571.10584392 9.51533612L34.9245512 220.888266c.895485 5.339259 5.4953944 9.264746 10.9090413 9.309595H212.873162c4.063354.052298 7.552433-2.878529 8.202287-6.889921L255.894156 9.55634756c.38793-2.39205042-.301742-4.83321259-1.884012-6.66864602-1.582271-1.83543342-3.895174-2.87725865-6.318275-2.8460066L8.30813067.0006835ZM154.924006 152.768274h-53.314864L87.1731177 77.3482475h80.6694903l-12.918602 75.4200265Z" />
<path fill="url(#a)" d="M244.610824 77.2417255h-76.917048L154.78548 152.601582h-53.272329l-62.9023275 74.663219c1.9937259 1.723985 4.5356374 2.682649 7.1712751 2.704595H212.729383c4.060112.052256 7.546408-2.876232 8.195743-6.884424l23.685698-145.8432465Z" />
</g>
</svg>
3 changes: 3 additions & 0 deletions src/Enums/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
enum Provider: string implements HasLabel
{
case Bitbucket = 'bitbucket';
case Discord = 'discord';
case Facebook = 'facebook';
case Gitlab = 'gitlab';
case Github = 'github';
Expand All @@ -23,6 +24,7 @@ public function getLabel(): string
{
return match ($this) {
self::Bitbucket => 'Bitbucket',
self::Discord => 'Discord',
self::Facebook => 'Facebook',
self::Gitlab => 'GitLab',
self::Github => 'GitHub',
Expand All @@ -42,6 +44,7 @@ public function getIconView(): View
{
$viewName = match ($this) {
self::Bitbucket => 'filament-companies::components.socialite-icons.bitbucket',
self::Discord => 'filament-companies::components.socialite-icons.discord',
self::Facebook => 'filament-companies::components.socialite-icons.facebook',
self::Gitlab => 'filament-companies::components.socialite-icons.gitlab',
self::Github => 'filament-companies::components.socialite-icons.github',
Expand Down
16 changes: 16 additions & 0 deletions src/FilamentCompaniesServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

namespace Wallo\FilamentCompanies;

use Illuminate\Support\Facades\Event;
use Illuminate\Support\ServiceProvider;
use Livewire\Livewire;
use SocialiteProviders\Manager\SocialiteWasCalled;
use Wallo\FilamentCompanies\Http\Livewire\CompanyEmployeeManager;
use Wallo\FilamentCompanies\Http\Livewire\ConnectedAccountsForm;
use Wallo\FilamentCompanies\Http\Livewire\DeleteCompanyForm;
Expand Down Expand Up @@ -36,6 +38,8 @@ public function boot(): void
$this->configurePublishing();
$this->configureCommands();

$this->configureSocialiteProviders();

$this->app->booted(function () {
$this->configureComponents();
});
Expand Down Expand Up @@ -110,4 +114,16 @@ protected function configureCommands(): void
Console\InstallCommand::class,
]);
}

/**
* Configure the additional socialite providers.
*/
protected function configureSocialiteProviders(): void
{
Event::listen(function (SocialiteWasCalled $event) {
if (class_exists(\SocialiteProviders\Discord\Provider::class)) {
$event->extendSocialite('discord', \SocialiteProviders\Discord\Provider::class);
}
});
}
}

0 comments on commit e24a6ba

Please sign in to comment.