diff --git a/app/Container/Container.php b/app/Container/Container.php new file mode 100644 index 000000000..bd3e1fff6 --- /dev/null +++ b/app/Container/Container.php @@ -0,0 +1,36 @@ +resolve($id); + } + + /** + * Check if a service exists in the container + */ + public function has(string $id): bool + { + return $this->bound($id); + } +} diff --git a/app/Events/TorrentUploaded.php b/app/Events/TorrentUploaded.php new file mode 100644 index 000000000..1727b6a35 --- /dev/null +++ b/app/Events/TorrentUploaded.php @@ -0,0 +1,66 @@ +torrentId; + } + + /** + * Get the uploader user ID + */ + public function getUploaderId(): int + { + return $this->uploaderId; + } + + /** + * Get the torrent name + */ + public function getTorrentName(): string + { + return $this->torrentName; + } + + /** + * Get the torrent size in bytes + */ + public function getSize(): int + { + return $this->size; + } + + /** + * Get the upload timestamp + */ + public function getUploadedAt(): DateTimeInterface + { + return $this->uploadedAt; + } +} diff --git a/app/Events/UserRegistered.php b/app/Events/UserRegistered.php new file mode 100644 index 000000000..3298e518c --- /dev/null +++ b/app/Events/UserRegistered.php @@ -0,0 +1,57 @@ +userId; + } + + /** + * Get the username + */ + public function getUsername(): string + { + return $this->username; + } + + /** + * Get the email + */ + public function getEmail(): string + { + return $this->email; + } + + /** + * Get the registration timestamp + */ + public function getRegisteredAt(): DateTimeInterface + { + return $this->registeredAt; + } +} diff --git a/app/Exceptions/.keep b/app/Exceptions/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php new file mode 100644 index 000000000..9f5d96458 --- /dev/null +++ b/app/Exceptions/Handler.php @@ -0,0 +1,48 @@ +getMessage() . ' in ' . $exception->getFile() . ':' . $exception->getLine()); + + // You can add custom handling here + } + + /** + * Render an exception for HTTP response + */ + public function render(Throwable $exception): string + { + if (php_sapi_name() === 'cli') { + return $exception->getMessage() . "\n"; + } + + // Return JSON for API requests or HTML for web + $isJson = isset($_SERVER['HTTP_ACCEPT']) && str_contains($_SERVER['HTTP_ACCEPT'], 'application/json'); + + if ($isJson) { + return json_encode([ + 'error' => $exception->getMessage(), + 'code' => $exception->getCode() + ]); + } + + return '

Error

' . htmlspecialchars($exception->getMessage()) . '

'; + } +}