From e1382a8b90443b71c3b99680cf5cc25a7ce3b4c5 Mon Sep 17 00:00:00 2001
From: Aan Choesni Herlingga <aanchoesni@unesa.ac.id>
Date: Wed, 5 Aug 2020 15:50:51 +0700
Subject: [PATCH] bug fix team

---
 app/Http/Controllers/Webprofile/Backend/PersonController.php |  2 +-
 app/Http/Controllers/Webprofile/Front/PersonController.php   | 12 +++++++-----
 resources/views/webprofile/backend/person/index.blade.php    |  2 +-
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/app/Http/Controllers/Webprofile/Backend/PersonController.php b/app/Http/Controllers/Webprofile/Backend/PersonController.php
index 9725c20..8bb9615 100644
--- a/app/Http/Controllers/Webprofile/Backend/PersonController.php
+++ b/app/Http/Controllers/Webprofile/Backend/PersonController.php
@@ -16,7 +16,7 @@ class PersonController extends Controller
 
         $pick = Setting::where('name_setting', 'team')->first();
 
-        $listTeam = null;
+        $listTeam = [];
         if ($pick) {
             $listTeam = $this->listTeam($pick->value_setting);
         }
diff --git a/app/Http/Controllers/Webprofile/Front/PersonController.php b/app/Http/Controllers/Webprofile/Front/PersonController.php
index 62b1f9f..1990f72 100644
--- a/app/Http/Controllers/Webprofile/Front/PersonController.php
+++ b/app/Http/Controllers/Webprofile/Front/PersonController.php
@@ -78,17 +78,19 @@ class PersonController extends Controller
     {
         $pick = Setting::where('name_setting', 'team')->first();
 
-        $listTeam = null;
+        $listTeam = [];
 
         if ($pick) {
             $listTeam = $this->listTeam($pick->value_setting);
         }
 
         $team = [];
-        if ($name == 'lecturer') {
-            $team = $listTeam[1];
-        } elseif ($name == 'academic-staff') {
-            $team = $listTeam[0];
+        if ($listTeam) {
+            if ($name == 'lecturer') {
+                $team = $listTeam[1];
+            } elseif ($name == 'academic-staff') {
+                $team = $listTeam[0];
+            }
         }
 
         return $team;
diff --git a/resources/views/webprofile/backend/person/index.blade.php b/resources/views/webprofile/backend/person/index.blade.php
index b85bc97..411f012 100644
--- a/resources/views/webprofile/backend/person/index.blade.php
+++ b/resources/views/webprofile/backend/person/index.blade.php
@@ -29,7 +29,7 @@
 	                    <div class="form-group @if ($errors->has('value_setting')) has-error @endif">
 	                        <label class="col-md-2 control-label">@lang('label.name') @lang('feature.setting')</label>
 	                        <div class="col-md-10">
-	                          {{ Form::select('value_setting', $unit, $pick->value_setting, ['class' => 'form-control select2', 'style' => 'width: 100%; font-size: 14pt;', 'id' => 'value_setting', 'placeholder' => app('translator')->getFromJson('feature.category'), 'required']) }}
+	                          {{ Form::select('value_setting', $unit, $pick ? $pick->value_setting : null, ['class' => 'form-control select2', 'style' => 'width: 100%; font-size: 14pt;', 'id' => 'value_setting', 'placeholder' => app('translator')->getFromJson('feature.category'), 'required']) }}
 	                          @if ($errors->has('value_setting'))
 	                          <label id="login-error" class="error" for="login">{{$errors->first('value_setting')}}</label>
 	                          @endif
--
libgit2 0.26.0