Skip to content

Commit

Permalink
use findOrFail for dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdulici committed Nov 2, 2020
1 parent 61ee01a commit 24a5e8a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/Http/Controllers/Common/Dashboards.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use App\Traits\DateTime;
use App\Traits\Users;
use App\Utilities\Widgets;
use Illuminate\Database\Eloquent\ModelNotFoundException;

class Dashboards extends Controller
{
Expand Down Expand Up @@ -51,9 +52,9 @@ public function show($dashboard_id = null)
{
$dashboard_id = $dashboard_id ?? session('dashboard_id');

if (!empty($dashboard_id)) {
$dashboard = Dashboard::find($dashboard_id);
} else {
try {
$dashboard = Dashboard::findOrFail($dashboard_id);
} catch (ModelNotFoundException $e) {
$dashboard = user()->dashboards()->enabled()->first();
}

Expand Down

0 comments on commit 24a5e8a

Please sign in to comment.