From ba5057181e688b896983785c50ec94ec302b1f19 Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 16 Feb 2018 18:04:11 -0800 Subject: [PATCH] Check for model in asset view --- resources/views/hardware/view.blade.php | 55 ++++++++++++++++--------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/resources/views/hardware/view.blade.php b/resources/views/hardware/view.blade.php index 1e4120b464..666e432149 100755 --- a/resources/views/hardware/view.blade.php +++ b/resources/views/hardware/view.blade.php @@ -33,7 +33,16 @@ @section('content')
- + + @if (!$asset->model) +
+
+

NO MODEL ASSOCIATED

+

This will break things in weird and horrible ways. Edit this asset now to assign it a model.

+
+
+ @endif + @if ($asset->deleted_at!='')
@@ -148,7 +157,7 @@ @endif - @if ($asset->model->manufacturer) + @if (($asset->model) && ($asset->model->manufacturer)) {{ trans('admin/hardware/form.manufacturer') }} @@ -162,21 +171,21 @@
  • {{ $asset->model->manufacturer->name }}
  • @endcan - @if ($asset->model->manufacturer->url) + @if (($asset->model) && ($asset->model->manufacturer->url))
  • {{ $asset->model->manufacturer->url }}
  • @endif - @if ($asset->model->manufacturer->support_url) + @if (($asset->model) && ($asset->model->manufacturer->support_url))
  • {{ $asset->model->manufacturer->support_url }}
  • @endif - @if ($asset->model->manufacturer->support_phone) + @if (($asset->model) && ($asset->model->manufacturer->support_phone))
  • {{ $asset->model->manufacturer->support_phone }}
  • @endif - @if ($asset->model->manufacturer->support_email) + @if (($asset->model) && ($asset->model->manufacturer->support_email))
  • {{ $asset->model->manufacturer->support_email }}
  • @endif @@ -188,7 +197,7 @@ {{ trans('general.category') }} - @if ($asset->model->category) + @if (($asset->model) && ($asset->model->category)) @can('view', \App\Models\Category::class) @@ -208,15 +217,21 @@ - {{ trans('admin/hardware/form.model') }} + {{ trans('admin/hardware/form.model') }} + - @can('view', \App\Models\AssetModel::class) - - {{ $asset->model->name }} - - @else - {{ $asset->model->name }} - @endcan + + @if ($asset->model) + + @can('view', \App\Models\AssetModel::class) + + {{ $asset->model->name }} + + @else + {{ $asset->model->name }} + @endcan + + @endif @@ -224,12 +239,12 @@ {{ trans('admin/models/table.modelnumber') }} - {{ $asset->model->model_number }} + {{ ($asset->model) ? $asset->model->model_number : ''}} - @if ($asset->model->fieldset) + @if (($asset->model) && ($asset->model->fieldset)) @foreach($asset->model->fieldset->fields as $field) @@ -326,7 +341,7 @@ @endif - @if ($asset->depreciation) + @if (($asset->model) && ($asset->depreciation)) {{ trans('general.depreciation') }} @@ -352,7 +367,7 @@ @endif - @if ($asset->model->eol) + @if (($asset->model) && ($asset->model->eol)) {{ trans('admin/hardware/form.eol_rate') }} @@ -448,7 +463,7 @@
    @if ($asset->image) - @elseif ($asset->model->image!='') + @elseif (($asset->model) && ($asset->model->image!='')) @endif