Show if there are database errors

This commit is contained in:
Nabeel Shahzad
2019-05-10 19:31:11 -05:00
parent a90d9aac39
commit 4dd3fc5244
5 changed files with 32 additions and 2 deletions
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Frontend;
use App\Interfaces\Controller; use App\Interfaces\Controller;
use App\Models\User; use App\Models\User;
use Illuminate\Database\QueryException; use Illuminate\Database\QueryException;
use Log;
/** /**
* Class HomeController * Class HomeController
@@ -18,6 +19,12 @@ class HomeController extends Controller
{ {
try { try {
$users = User::orderBy('created_at', 'desc')->take(4)->get(); $users = User::orderBy('created_at', 'desc')->take(4)->get();
debug($users);
} catch (\PDOException $e) {
Log::emergency($e);
return view('system/errors/database_error', [
'error' => $e->getMessage(),
]);
} catch (QueryException $e) { } catch (QueryException $e) {
return view('system/errors/not_installed'); return view('system/errors/not_installed');
} }
+10
View File
@@ -36,3 +36,13 @@ services:
- ./docker/data/mysql:/var/lib/mysql - ./docker/data/mysql:/var/lib/mysql
ports: ports:
- 3306:3306 - 3306:3306
# Use this to tail the logs so it's just all in a single window
logs:
image: busybox
command: tail -f /var/www/storage/logs/laravel.log
restart: always
volumes:
- ./:/var/www
depends_on:
- app
+11 -1
View File
@@ -1,3 +1,13 @@
FROM php:7.3-fpm FROM php:7.3-fpm
RUN docker-php-ext-install mysqli pdo openssl mbstring tokenizer curl json gmp RUN docker-php-ext-install \
mysqli \
pdo \
openssl \
mbstring \
tokenizer \
curl \
json \
gmp
RUN ln -sf /dev/stderr /var/log/fpm-error.log
+3
View File
@@ -10,3 +10,6 @@ pm.max_children = 5
pm.start_servers = 2 pm.start_servers = 2
pm.min_spare_servers = 1 pm.min_spare_servers = 1
pm.max_spare_servers = 3 pm.max_spare_servers = 3
php_flag[display_errors] = on
php_admin_flag[log_errors] = on
@@ -62,7 +62,7 @@
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<h2>Database Error</h2> <h2>Database Error</h2>
@yield('content') {{ $error }}
</div> </div>
</div> </div>
</div> </div>