From 73a8ae2841554e0681b21d9bec2ba08e4bddf6ec Mon Sep 17 00:00:00 2001 From: Kathryn Anne S Tan Date: Tue, 10 Sep 2024 14:30:33 +0300 Subject: [PATCH] Fix article readme, handle when no documents in db --- _readme/display_isolated_fly_replay_livewire.md | 2 +- app/Http/Controllers/DocumentController.php | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/_readme/display_isolated_fly_replay_livewire.md b/_readme/display_isolated_fly_replay_livewire.md index 2d9f6ce..fd7d825 100644 --- a/_readme/display_isolated_fly_replay_livewire.md +++ b/_readme/display_isolated_fly_replay_livewire.md @@ -2,7 +2,7 @@ Running global instances of our Laravel applications allows us to reduce geographical latency for users across different regions. But with it comes the responsibility of addressing regional-isolation of not only data, but files as well. -In [this article](/laravel-bytes/displaying-fly-replay-livewire/) we address file isolation by talking with the right regional instance using fly-replay. We also add a cherry on top with the use of Livewire's `wire:init` directive to improve loading of pages displaying PDF files. +In [this article](https://fly.io/laravel-bytes/displaying-fly-replay-livewire/) we address file isolation by talking with the right regional instance using fly-replay. We also add a cherry on top with the use of Livewire's `wire:init` directive to improve loading of pages displaying PDF files. ## Relevant files 1. We've added routes to a documents module in [`web.php`](https://github.com/KTanAug21/fly.io-livewire-snippets/blob/master/routes/web.php) diff --git a/app/Http/Controllers/DocumentController.php b/app/Http/Controllers/DocumentController.php index 4f1ecf9..17532d5 100644 --- a/app/Http/Controllers/DocumentController.php +++ b/app/Http/Controllers/DocumentController.php @@ -28,9 +28,13 @@ public function index() public function display($id) { $pdfDetails = Document::find($id); - Log::info('our config var value is '.config('app.fly_region') ); - + // None found, don + if ( $pdfDetails == null ){ + return null; + } + // Decide replay + Log::info('our config var value is '.config('app.fly_region') ); if( $pdfDetails->region_id != config('app.fly_region') ){ // Replay to identified region