Compare commits
No commits in common. "061b4a84c111668a0fd6e4cc1874abea8ad9d59f" and "1b071ef37e06129207467b170475d9ee1276cabf" have entirely different histories.
061b4a84c1
...
1b071ef37e
|
@ -114,10 +114,10 @@ abstract class EventManager extends ComponentBase
|
|||
|
||||
private function getPageFromProperty(string $property): Page
|
||||
{
|
||||
throw_if(!$this->property('indexPage') || !$this->property('singlePage') || !$this->property('registerPage'), ComponentException::class, 'not_all_pages_set');
|
||||
throw_if(!$this->property('indexPage') || !$this->property('singlePage') || !$this->property('registerPage'), ComponentException::class, 'silva.adrema::lang.not_all_pages_set');
|
||||
|
||||
$page = Page::find($this->property($property));
|
||||
throw_if($page === null, ComponentException::class, 'page_not_found');
|
||||
throw_if($page === null, ComponentException::class, 'silva.adrema::lang.page_not_found');
|
||||
|
||||
return $page;
|
||||
}
|
||||
|
@ -131,8 +131,8 @@ abstract class EventManager extends ComponentBase
|
|||
$singlePage = $this->getPageFromProperty('singlePage');
|
||||
$registerPage = $this->getPageFromProperty('registerPage');
|
||||
|
||||
throw_if(!str($singlePage->url)->contains(':slug'), ComponentException::class, 'slug_not_found');
|
||||
throw_if(!str($registerPage->url)->contains(':slug'), ComponentException::class, 'slug_not_found');
|
||||
throw_if(!str($singlePage->url)->contains(':slug'), ComponentException::class, 'silva.adrema::lang.slug_not_found');
|
||||
throw_if(!str($registerPage->url)->contains(':slug'), ComponentException::class, 'silva.adrema::lang.slug_not_found');
|
||||
|
||||
return [
|
||||
'indexUrl' => $indexPage->url,
|
||||
|
|
|
@ -12,7 +12,7 @@ class ComponentException extends ApplicationException
|
|||
|
||||
public function __construct($message = "", $code = 0, Throwable $previous = null)
|
||||
{
|
||||
$translations = include(__DIR__ . '/../lang/en/lang.php');
|
||||
$translations = json_decode(file_get_contents(__DIR__ . '/../lang/en.json'), true);
|
||||
|
||||
parent::__construct($translations['errors.' . $message] ?? $message, $code, $previous);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ class FetchSingleEvent
|
|||
public function run(string $slug): ?array
|
||||
{
|
||||
$events = data_get(app(FetchAllEvents::class)->run(), 'data');
|
||||
throw_if(is_null($events), ComponentException::class, 'event_fetching_failed');
|
||||
throw_if(is_null($events), ComponentException::class, 'silva.adrema::lang.event_fetching_failed');
|
||||
|
||||
return collect($events)->first(fn ($event) => $event['slug'] === $slug);
|
||||
}
|
||||
|
|
|
@ -20,13 +20,13 @@ class Proxy
|
|||
|
||||
protected function get(string $url): ?array
|
||||
{
|
||||
$response = Http::header('Accept', 'application/json')->get($this->url($url));
|
||||
$response = Http::acceptJson()->get($this->url($url));
|
||||
|
||||
if (!$response->ok) {
|
||||
if (!$response->ok()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return json_decode($response->body, true);
|
||||
return $response->json();
|
||||
}
|
||||
|
||||
public function submit(string $url): JsonResponse
|
||||
|
@ -36,12 +36,9 @@ class Proxy
|
|||
'Authorization' => 'Bearer ' . request()->header('X-Adrema-Token'),
|
||||
]
|
||||
: [];
|
||||
$response = Http::make($this->url($url), 'POST')
|
||||
->setOption(CURLOPT_POSTFIELDS, json_encode(request()->input()))
|
||||
->header([...$headers, 'Accept' => 'application/json', 'Content-Type' => 'application/json'])
|
||||
->send();
|
||||
$response = Http::acceptJson()->withHeaders($headers)->post($this->url($url), request()->input());
|
||||
|
||||
return response()->json(json_decode($response->body, true), $response->code);
|
||||
return response()->json($response->json(), $response->status());
|
||||
}
|
||||
|
||||
private function url(string $internal): string
|
||||
|
|
Loading…
Reference in New Issue