??????????????
<?php
namespace App\Libs;

use App\ShceduleDay;
use App\ScheduleExcept;
use App\Schedule;
use Carbon\Carbon;
use App\Size;

class Endhour
{
    public $arr;
    public $dat;
    public function fromTime($h = null)
    {
        if ($h != null) {
            if(is_array($h)){
                $hh = [];
                $hh[0] = $h['start'];
                $hh[1] = $h['end'];
            } else {
                $hh = explode(':', $h);
            }
            if ($hh[1] == '00') {
                $hhh = '30';
                $ho = 0;
            } elseif ($hh[1] == '30') {
                $hhh = '00';
                $ho = 1;
            } else {
                $hhh = '30';
                $ho = 0;
            }
$hoo0 = (int)$hh[0];
            $hhhh = strval($hoo0 + $ho);

            $hhhhh = $hhhh . ':' . $hhh;
            return $hhhhh;
        }
    }
    public function orderObj($obj = null){

        $sd = \App::make('\App\Libs\Sum')->getPrice($obj->width, $obj->height);

        $cookie_price = Size::where('size', $sd)->where('catalogs_id', $obj->catalogs_id)->first();
        if($cookie_price != null){
            $p = $cookie_price->price;
        }else{
            $p = $obj->price;
        }
        $hh = ceil($p / 80) / 2;
        //dd($sd, $cookie_price->price, $h, $cat_id, $width, $height);
        if ($hh > 4) {
            $hh = 4;
        }
        $dat = Carbon::parse($obj->putdate)->format('d-m-Y');
        $datD = Carbon::parse($obj->putdate)->format('D');
        $time = Carbon::parse($obj->putdate)->format('H:i');
        $t_day = ShceduleDay::where('day', $dat)->where('saloon_id', $obj->saloon_id)->where('artist_id', $obj->artist_id)->orderBy('id','DESC')->first();
        if (!isset($t_day)) {
            $t_day = ScheduleExcept::where('day', $datD)->where('saloon_id', $obj->saloon_id)->where('artist_id', $obj->artist_id)->orderBy('id','DESC')->first();
            if(!isset($t_day)){
                $t_day = Schedule::where('saloon_id', $obj->saloon_id)->where('artist_id', $obj->artist_id)->orderBy('id','DESC')->first();
                if(!isset($t_day)){
                    $t_day = Schedule::where('saloon_id', $obj->saloon_id)->where('artist_id', 0)->orderBy('id','DESC')->first();
                }
            }
        }
        $t_arr = unserialize($t_day->hours);
        // $time_obj = new Endhour();
        $key = array_search($time, $t_arr);

        for ($i = (int)$key; $i < (int)$key + $hh*2; $i++) {
            unset($t_arr[$i]);
            //echo $t_arr[$i]."<br />";
        }
        $this->arr = $t_arr;
        $this->dat = $dat;
        //dd($hh, $time, $t_arr, (int)$key, $datD, $t_d