Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 24
HolidayHelper
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 2
182
0.00% covered (danger)
0.00%
0 / 24
 getholidayList
0.00% covered (danger)
0.00%
0 / 1
156
0.00% covered (danger)
0.00%
0 / 23
 gettodayholiday
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
<?php
namespace App\Helpers;
use App\Models\Auth\User;
use App\Models\Admin\Team;
use Carbon\Carbon;
use App\Models\Admin\UserDetail;
use App\Models\Admin\HolidayList;
use Illuminate\Support\Facades\Auth;
use DB;
class HolidayHelper{
    public static function getholidayList($user_id){
        $userdetail = UserDetail::select('holiday_list_id','primary_team_id')
                        ->where('user_id','=',$user_id)
                        ->first();
        $holidayIds = array();
        if(!empty($userdetail)){
        
        $holidayListId = '';
        $team = Team::where('id','=',$userdetail->primary_team_id)->first();
     
        if($team !== null && $team->has_schedule == true && $team->has_holiday == false ) //if the team is in schedule the holiday list is not applicable
        {
            return $holidayIds;
        }
        
        if(isset($userdetail->holiday_list_id) && !is_null($userdetail->holiday_list_id))
        {
            $holidayListId = $userdetail->holiday_list_id;
        }
        elseif (isset($team->holiday_list_id) && !empty($team->holiday_list_id)) {
            $holidayListId = $team->holiday_list_id;
        }
        else {
            $holidaylist = HolidayList::where('is_default','=','1')->first();
            if(!empty($holidaylist)){
            $holidayListId = $holidaylist->id;
            }
        }
        if($holidayListId != null){
        $holidays = DB::table('holiday_holiday_list')
                    ->where('holiday_list_id','=',$holidayListId)
                    ->get();
     
        foreach ($holidays as $holiday) {
            array_push($holidayIds, $holiday->holiday_id);
        }
        }
        //$holidayIds = implode(",",$holidayIds);
        }
        return $holidayIds;
       
    }
    public static function gettodayholiday($user_id)
    {
        
    }
}
?>