first commit
Some checks failed
Build / run (push) Has been cancelled

This commit is contained in:
maher
2025-10-29 11:42:25 +01:00
commit 703f50a09d
4595 changed files with 385164 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
<?php
namespace App\Services\Settings\Validators;
use App\Services\Data\Tmdb\TmdbApi;
use Common\Settings\Validators\SettingsValidator;
use GuzzleHttp\Exception\ClientException;
use Illuminate\Support\Arr;
class TmdbApiKeyValidator implements SettingsValidator
{
public const KEYS = ['tmdb_api_key'];
public function fails($values)
{
if ($apiKey = Arr::get($values, 'tmdb_api_key')) {
config(['services.tmdb.key' => $apiKey]);
}
try {
app(TmdbApi::class)->browse();
} catch (ClientException $e) {
$errResponse = json_decode(
$e
->getResponse()
->getBody()
->getContents(),
true,
512,
JSON_THROW_ON_ERROR,
);
return $this->getMessage($errResponse);
}
}
/**
* @param array $errResponse
* @return array
*/
private function getMessage($errResponse)
{
return ['tmdb_api_key' => 'This Themoviedb api key is not valid.'];
}
}