-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added a proper function to the token callback controller (#738)
- Loading branch information
Showing
23 changed files
with
607 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
app/Actions/Models/List/BaseStoreExternalProfileAction.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Actions\Models\List; | ||
|
||
use App\Enums\Models\List\ExternalProfileSite; | ||
use App\Models\Wiki\Anime; | ||
use App\Models\Wiki\ExternalResource; | ||
use Illuminate\Support\Arr; | ||
use Illuminate\Support\Collection; | ||
|
||
/** | ||
* Class BaseStoreExternalProfileAction. | ||
*/ | ||
abstract class BaseStoreExternalProfileAction | ||
{ | ||
protected Collection $resources; | ||
|
||
/** | ||
* Preload the resources for performance proposals. | ||
* | ||
* @param ExternalProfileSite $profileSite | ||
* @param array $entries | ||
* @return void | ||
*/ | ||
protected function preloadResources(ExternalProfileSite $profileSite, array $entries): void | ||
{ | ||
$externalResources = ExternalResource::query() | ||
->where(ExternalResource::ATTRIBUTE_SITE, $profileSite->getResourceSite()->value) | ||
->whereIn(ExternalResource::ATTRIBUTE_EXTERNAL_ID, Arr::pluck($entries, 'external_id')) | ||
->with(ExternalResource::RELATION_ANIME) | ||
->get() | ||
->mapWithKeys(fn (ExternalResource $resource) => [$resource->external_id => $resource->anime]); | ||
|
||
$this->resources = $externalResources; | ||
} | ||
|
||
/** | ||
* Get the animes by the external id. | ||
* | ||
* @param int $externalId | ||
* @return Collection<int, Anime> | ||
*/ | ||
protected function getAnimesByExternalId(int $externalId): Collection | ||
{ | ||
return $this->resources[$externalId] ?? new Collection(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.