use findOrFail for dashboard
This commit is contained in:
parent
61ee01ab4c
commit
24a5e8a3a6
@ -13,6 +13,7 @@ use App\Models\Common\Widget;
|
|||||||
use App\Traits\DateTime;
|
use App\Traits\DateTime;
|
||||||
use App\Traits\Users;
|
use App\Traits\Users;
|
||||||
use App\Utilities\Widgets;
|
use App\Utilities\Widgets;
|
||||||
|
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||||
|
|
||||||
class Dashboards extends Controller
|
class Dashboards extends Controller
|
||||||
{
|
{
|
||||||
@ -51,9 +52,9 @@ class Dashboards extends Controller
|
|||||||
{
|
{
|
||||||
$dashboard_id = $dashboard_id ?? session('dashboard_id');
|
$dashboard_id = $dashboard_id ?? session('dashboard_id');
|
||||||
|
|
||||||
if (!empty($dashboard_id)) {
|
try {
|
||||||
$dashboard = Dashboard::find($dashboard_id);
|
$dashboard = Dashboard::findOrFail($dashboard_id);
|
||||||
} else {
|
} catch (ModelNotFoundException $e) {
|
||||||
$dashboard = user()->dashboards()->enabled()->first();
|
$dashboard = user()->dashboards()->enabled()->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user