'required', ); /* * get all centre_attributes * created on: 24/07/2017 */ public static function manage($conditions = array()){ //pr($conditions); die; $result = Centre::Select( 'centre_attributes.id', 'centre_attributes.centre_id', 'centre_attributes.book_cutoff_time', 'centre_attributes.book_time_window', 'centre_attributes.post_surgery_period', 'centre_attributes.weekday', 'centre_attributes.image', 'centre_attributes.address_en', 'centre_attributes.pincode_en', 'centre_attributes.latitude', 'centre_attributes.longitude', 'centre_attributes.address_hin', 'centre_attributes.pincode_hin', 'centre_attributes.working_hrs', 'centre_attributes.phone', 'centre_attributes.whatsapp_no', 'centre_attributes.call_us', 'centre_attributes.email', 'centre_attributes.embeddedurl', 'centre_attributes.vision_hospital', 'centre_attributes.state_id', 'states.name', 'centre_attributes.sequence', 'centres.centre_name_en', 'users.first_name', 'users.last_name', 'users_updated.first_name as updated_by_first_name', 'users_updated.last_name as updated_by_last_name', 'centre_attributes.added_on', 'centre_attributes.updated_on' ); $result->leftjoin('states', 'centre_attributes.state_id', '=', 'states.id'); $result->leftjoin('users', 'centre_attributes.added_by', '=', 'users.id'); $result->leftjoin('users as users_updated', 'centre_attributes.updated_by', '=', 'users_updated.id'); $result->leftjoin('centres', 'centre_attributes.centre_id', '=', 'centres.id'); $result->where(array('centre_attributes.flag' => 0)); if(isset($conditions['options']) && isset($conditions['keyword']) && !empty($conditions['options']) && !empty($conditions['keyword'])){ if($conditions['options'] == 'centres.centre_name_en'){ $result->where('centre_attributes.centre_id', '=' ,$conditions['keyword'] ); } else { $result->where($conditions['options'], 'like', '%'.$conditions['keyword'].'%'); } } if (isset($conditions['centre_attributes.slug']) && !empty($conditions['centre_attributes.slug'])) { $result->where($conditions); } if(isset($conditions['order_field']) && isset($conditions['order_by']) && !empty($conditions['order_field']) && !empty($conditions['order_by'])){ $result->orderBy($conditions['order_field'], $conditions['order_by']); }else{ $result->orderBy('id', 'desc'); } $totalCount = $result->count(); if(isset($conditions['start']) && isset($conditions['limit']) && !empty($conditions['limit'])){ $result->offset($conditions['start'])->limit($conditions['limit'])->orderBy('id','desc'); } if(isset($conditions['centre_attributes.id']) && !empty($conditions['centre_attributes.id'])){ $result->where($conditions); $results = $result->first(); return $results; } $results = $result->get(); // pr($results); die; if($totalCount){ if(count($results) > 0){ foreach ($results as $key => $value) { $value->added_by = !empty($value->first_name) ? $value->first_name ." ". $value->last_name : 'N/A'; $value->updated_by = !empty($value->updated_by_first_name) ? $value->updated_by_first_name ." ". $value->updated_by_last_name : 'N/A'; } } return array('results' => $results, 'total_count' => $totalCount); }else{ return false; } } /* * check duplicate state * created on: 26/07/2017 */ public static function duplicateCheck($param = []) { //pr($param); die; $result = DB::table('centre_attributes'); $result->where(array('flag' => 0, 'centre_id'=> $param['centre_id'])); if(isset($param['id']) && !empty($param['id'])){ $result->where('id', '!=', $param['id']); } $results = $result->count(); if($results >= 1){ return true; }else{ return false; } } /* * Delete multiple States * Created on: 26/07/2017 */ public static function deletemultiple($param){ $result = DB::table('centre_attributes') ->whereIn('id' , $param) ->update(array('flag' => 2,'updated_by' => Auth::user()->id,'updated_on' => date('Y-m-d H:i:s'))); if($result){ return true; }else{ return false; } } // public function getViewimageAttribute(){ // $imageattr = !empty($this->attributes['image'])?asset('storage/centre_attributes/'.$this->attributes['image']):asset('storage/no_image.jpg'); // $html = ''; // return $html; // } public static function duplicateCheck1($param = array()){ $result = DB::table('centres'); $result->where(array('flag' => 0,'centre_name_en'=> $param['centre_name_en'])); $results = $result->count(); if($results >= 1){ return true; }else{ return false; } } public function getWeeklyOffAttribute(){ $var = ""; $arr = [0 => "Sunday", 1 => "Monday", 2 => "Tuesday", 3 => "Wednesday", 4 => "Thursday", 5 => "Friday", 6 => "Saturday" ]; $week_off = explode(',', $this->attributes['weekday']); if( count($week_off) > 0){ foreach ($week_off as $key => $value) { $var .= $arr[$value] . ', ' ; } } return rtrim($var," ,"); } public function getViewImageAttribute(){ $image = !empty($this->image) ? asset('storage/Centre_Image/'.$this->image) : ''; return !empty($this->image) ? '':'N/A'; } public function getVisHospitalAttribute(){ $res = !empty($this->attributes['vision_hospital'] == 1 ) ? "Vision Centre" : 'Hospital'; return $res; } }