protected function imageAvatar()
 {
     $path = 'upload/' . date('Ym/d/');
     $filename = KRandom::getRandStr() . '.jpg';
     if (!File::exists(public_path($path))) {
         File::makeDirectory(public_path($path), 493, true);
     }
     while (File::exists(public_path($path) . $filename)) {
         $filename = KRandom::getRandStr() . '.jpg';
     }
     $this->image->resize(new \Imagine\Image\Box(300, 300))->save(public_path($path) . $filename);
     ImageModel::createUploadedImage($path . $filename, URL::asset($path . $filename));
     $user = AuthModel::user();
     $url = URL::asset($path . $filename);
     if ($user) {
         if ($user->profile) {
             $user->profile->avatar = $url;
             $user->profile->save();
         } else {
             ProfileModel::create(array('user_id' => $user->id, 'avatar' => $url));
         }
     } else {
     }
     return $url;
 }
 /**
  * GET DISTANCE BETWEEN LOCATION AND CAFES
  * @param $lat1
  * @param $lon1
  * @param $lat2
  * @param $lon2
  * @param $unit
  * @param $limit
  * @param $id
  * @return array|bool
  */
 public function distance($lat1, $lon1, $lat2, $lon2, $unit, $limit, $id)
 {
     $theta = $lon1 - $lon2;
     $dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
     $dist = acos($dist);
     $dist = rad2deg($dist);
     $miles = $dist * 60 * 1.1515;
     $unit = strtoupper($unit);
     //$miles = round($miles);
     $location = $this->cafe->find($id);
     $phone = $location->phone ? '<br/>' . $location->phone : null;
     if (strlen($location->image) < 1) {
         $image = URL::asset('library/img/loc-noimg.jpg');
     } else {
         $image = URL::asset('uploads/store_images/' . $location->image);
     }
     $array = array();
     if ($miles <= $limit) {
         array_push($array, ['image' => $image, 'miles' => intval($miles), 'id' => $location->id, 'name' => $location->name, 'address' => $location->address . '<br/>' . $location->city . ', ' . $location->state . ' ' . $location->zip_code . $phone, 'lat' => $location->lat, 'lng' => $location->lng, 'state' => $location->state, 'country' => $location->country, 'bakery' => $location->bakery, 'icecream' => $location->icecream, 'coffee' => $location->coffee, 'frozenyogurt' => $location->frozenyogurt, 'smoothies' => $location->smoothies, 'wifi' => $location->wifi, 'curbside' => $location->curbside, 'cookie' => $location->cookie, 'savory' => $location->savory, 'map' => $location->maps_url, 'facebook' => $location->facebook_url, 'online_order' => $location->online_order, 'coming_soon' => $location->coming_soon]);
         return $array;
     }
     return false;
     //return $miles;
     //        if ($unit == "K") {
     //            return ($miles * 1.609344);
     //        } else if ($unit == "N") {
     //            return ($miles * 0.8684);
     //        } else {
     //            return round($miles). ' Miles';
     //        }
 }
 public function getDrawResult()
 {
     $userId = $this->getRandomUserId();
     $user = $this->getUser($userId);
     $user['profileImage'] = URL::asset('uploads/' . $user->image);
     $response = array('status' => true, 'user' => $user);
     return Response::json($response);
 }
Exemple #4
0
 public static function asset($uri)
 {
     if (preg_match('/^http|https\\:\\/\\/.*/i', $uri)) {
         return $uri;
     } else {
         $version = static::$version ? static::$version . '/' : '';
         return URL::asset("packages/xjtuwangke/laravel-cms/{$version}{$uri}");
     }
 }
Exemple #5
0
 public function getImageUrl($withBaseUrl = false)
 {
     if (!$this->icon) {
         return NULL;
     }
     $imgDir = '/images/languages/' . $this->id;
     $url = $imgDir . '/' . $this->icon;
     return $withBaseUrl ? URL::asset($url) : $url;
 }
Exemple #6
0
 /**
  * Generate URL from static CDN if STATIC_CDN_PATH is defined
  *
  * @param $path
  * @param bool|null $secure
  * @return string
  */
 function staticAsset($path, $secure = null)
 {
     if ($secure == null) {
         $secure = env('STATIC_CDN_SECURE', null);
     }
     if ($staticPath = env('STATIC_CDN_PATH', false)) {
         return URL::assetFrom($staticPath, $path, $secure);
     }
     return URL::asset($path, $secure);
 }
Exemple #7
0
 private function getListMultiple($row)
 {
     if (!$this->getValue($row)) {
         return '';
     }
     $images = json_decode($this->getValue($row), true);
     // FIXME: fix fixfix
     $html = '<div style="cursor:pointer;height: 50px;overflow: hidden;" onclick="$(this).css(\'height\', \'auto\').css(\'overflow\', \'auto\');">';
     foreach ($images as $source) {
         $src = $this->getAttribute('before_link') . $source['sizes']['original'] . $this->getAttribute('after_link');
         // FIXME: move to template
         $src = $this->getAttribute('is_remote') ? $src : URL::asset($src);
         $html .= '<img height="' . $this->getAttribute('img_height', '50px') . '" src="' . $src . '" /><br>';
     }
     $html .= '</div>';
     return $html;
 }
 public function editWorkstreamRiskOrIssue($programid, $workstreamid, $riskid)
 {
     $program = Program::findOrFail($programid);
     $workstream = WorkStream::findOrFail($workstreamid);
     $risk = Risk::findorFail($riskid);
     //return "Owner id: $risk->owner , Owner Name: $risk->OwnerName";
     $title = "Edit {$risk->title} for the {$workstream->name} Workstream";
     $breadcrumbs[] = ['Home', URL::asset('/home'), false];
     $breadcrumbs[] = ['Programs', URL::asset('programs'), false];
     $breadcrumbs[] = [$program->name, URL::asset('/') . "/programs/{$programid}", false];
     $breadcrumbs[] = ['Workstreams', '', false];
     $breadcrumbs[] = [$workstream->name, URL::asset('/') . "/programs/{$programid}/workstreams/{$workstreamid}", false];
     $breadcrumbs[] = ['Risks & Issues', '', false];
     $breadcrumbs[] = [$risk->title, '', false];
     $breadcrumbs[] = ['Edit', URL::asset('/') . "/programs/{$programid}/workstreams/{$workstreamid}/risksandissues/{$riskid}/edit", true];
     $redirect = "/programs/{$programid}/workstreams/{$workstreamid}";
     //return $risk->NextReviewDate;
     return $this->edit($risk, $title, $breadcrumbs, $redirect);
 }
 public static function getBreadCrumb($subjecttype, $subjectid)
 {
     $breadcrumbs[] = ['Home', URL::asset('/home'), false];
     switch ($subjecttype) {
         case "Program":
             $program = Program::findOrFail($subjectid);
             $programid = $program->id;
             $breadcrumbs[] = ['Programs', URL::asset('programs'), false];
             $breadcrumbs[] = [$program->name, URL::asset('/') . "/programs/{$programid}", false];
             return $breadcrumbs;
             break;
         case "WorkStream":
             $workstream = WorkStream::findOrFail($subjectid);
             $program = Program::findOrFail($workstream->program_id);
             $programid = $program->id;
             $workstreamid = $workstream->id;
             $breadcrumbs[] = ['Programs', URL::asset('programs'), false];
             $breadcrumbs[] = [$program->name, URL::asset('/') . "/programs/{$programid}", false];
             $breadcrumbs[] = ['Workstreams', '', false];
             $breadcrumbs[] = [$workstream->name, URL::asset('/') . "/programs/{$programid}/workstreams/{$workstreamid}", false];
             return $breadcrumbs;
             break;
         case "Project":
             $project = Project::findOrFail($subjectid);
             $workstream = WorkStream::findOrFail($project->work_stream_id);
             $program = Program::findOrFail($workstream->program_id);
             $programid = $program->id;
             $workstreamid = $workstream->id;
             $breadcrumbs[] = ['Programs', URL::asset('programs'), false];
             $breadcrumbs[] = [$program->name, URL::asset('/') . "/programs/{$programid}", false];
             $breadcrumbs[] = ['Workstreams', '', false];
             $breadcrumbs[] = [$workstream->name, URL::asset('/') . "/programs/{$programid}/workstreams/{$workstreamid}", false];
             $breadcrumbs[] = ['Projects', '', false];
             $breadcrumbs[] = [$project->name, URL::asset('/') . "/programs/{$programid}/workstreams/{$workstreamid}/projects/{$project->id}", false];
             return $breadcrumbs;
             break;
         case "Risk":
             $risk = Risk::findOrFail($subjectid);
             $breadcrumbs = Breadcrumbs::getBreadCrumb($risk->subject_type, $risk->subject_id);
             $breadcrumbs[] = ['Risks', '', false];
             $breadcrumbs[] = [$risk->title, URL::asset('risks/') . "/{$risk->id}", false];
             return $breadcrumbs;
             break;
         case "Action":
             $action = Action::findOrFail($subjectid);
             $breadcrumbs = Breadcrumbs::getBreadCrumb($action->subject_type, $action->subject_id);
             $breadcrumbs[] = ['Actions', URL::action('ActionController@index', [$action->subject_type, $action->subject_id]), false];
             $breadcrumbs[] = [$action->title, '', false];
             return $breadcrumbs;
             break;
         case "Rag":
             $rag = rag::findOrFail($subjectid);
             $breadcrumbs = Breadcrumbs::getBreadCrumb($rag->subject_type, $rag->subject_id);
             $breadcrumbs[] = ['RAGs', URL::action('RagController@index', [$rag->subject_type, $rag->subject_id]), false];
             $breadcrumbs[] = [$rag->title, '', false];
             return $breadcrumbs;
             break;
         case "Task":
             $task = Task::findOrFail($subjectid);
             $breadcrumbs = Breadcrumbs::getBreadCrumb($task->subject_type, $task->subject_id);
             $breadcrumbs[] = ['Tasks', URL::action('TaskController@indexTask', [$task->subject_type, $task->subject_id]), false];
             $breadcrumbs[] = [$task->title, URL::asset('tasks/') . "/{$task->id}", false];
             return $breadcrumbs;
             break;
         case "Dependency":
             $dependency = Dependency::findOrFail($subjectid);
             $breadcrumbs = Breadcrumbs::getBreadCrumb($dependency->subject_type, $dependency->subject_id);
             $breadcrumbs[] = ['Dependencies', URL::action('DependencyController@index', [$dependency->subject_type, $dependency->subject_id]), false];
             $breadcrumbs[] = [$dependency->title, URL::asset('dependencies/') . "/{$dependency->id}", false];
             return $breadcrumbs;
             break;
         case "ChangeRequest":
             $changerequest = ChangeRequest::findOrFail($subjectid);
             $breadcrumbs = Breadcrumbs::getBreadCrumb($changerequest->subject_type, $changerequest->subject_id);
             $breadcrumbs[] = ['Change Requests', URL::action('ChangeRequestController@index', [$changerequest->subject_type, $changerequest->subject_id]), false];
             $breadcrumbs[] = [$changerequest->title, URL::asset('changerequests/') . "/{$changerequest->id}", false];
             return $breadcrumbs;
             break;
         case "Link":
             $link = Link::findOrFail($subjectid);
             $breadcrumbs = Breadcrumbs::getBreadCrumb($link->subject_type, $link->subject_id);
             $breadcrumbs[] = ['Links', URL::action('LinkController@index', [$link->subject_type, $link->subject_id]), false];
             $breadcrumbs[] = [$link->title, URL::asset('links/') . "/{$link->id}", false];
             return $breadcrumbs;
             break;
     }
 }
Exemple #10
0
 /**
  * Return the item url
  *
  * @return string
  */
 public function thumbUrl()
 {
     $resourceUrl = $this->thumb();
     return URL::asset($resourceUrl);
 }
 /**
  * save & send email confirm doctor details
  * @param Request $request
  * @return \Illuminate\Http\JsonResponse
  */
 public function SaveSendEmailDoctorConfirm(Request $request)
 {
     try {
         $doctor_id = $request->doctor_id;
         $user_id = $request->user_id;
         $username = $request->username;
         $password = $request->password;
         /* Select patient record from table*/
         $re_patient = User::find($user_id);
         $re_patient->email = $username;
         $re_patient->password = md5($password);
         $re_patient->save();
         $doctor = Doctors::whereId($doctor_id)->first();
         $url = URL::asset('') . "DoctorAccount";
         $subject['sub'] = "Account Activated at eAyurveda.lk";
         $subject['email'] = $doctor->email;
         $subject['name'] = $doctor->first_name . ' ' . $doctor->last_name;
         Mail::send('emails.doctor_login_mail', ['name' => $subject['name'], 'url' => $url, 'username' => $username, 'password' => $password], function ($message) use($subject) {
             $message->to($subject['email'], $subject['name'])->subject($subject['sub']);
         });
         $res['CHECK'] = "Changed";
     } catch (Exception $e) {
         $res['CHECK'] = "Fail";
         $this->LogError('Admin_Front SaveDoctorConfirm Function', $e);
     }
     return response()->json($res);
 }
Exemple #12
0
 public function doUpload($file)
 {
     $extension = $file->guessExtension();
     $rawFileName = md5_file($file->getRealPath()) . '_' . time();
     $fileName = $rawFileName . '.' . $extension;
     $definitionName = $this->getOption('def_name');
     $prefixPath = 'storage/tb-' . $definitionName . '/';
     // FIXME: generate path by hash
     $postfixPath = date('Y') . '/' . date('m') . '/' . date('d') . '/';
     $destinationPath = $prefixPath . $postfixPath;
     $status = $file->move($destinationPath, $fileName);
     $data = array();
     $data['sizes']['original'] = $destinationPath . $fileName;
     $variations = $this->getAttribute('variations', array());
     foreach ($variations as $type => $methods) {
         $img = Image::make($data['sizes']['original']);
         foreach ($methods as $method => $args) {
             call_user_func_array(array($img, $method), $args);
         }
         $path = $destinationPath . $rawFileName . '_' . $type . '.' . $extension;
         $quality = $this->getAttribute('quality', 100);
         $img->save(public_path() . '/' . $path, $quality);
         $data['sizes'][$type] = $path;
     }
     $response = array('data' => $data, 'status' => $status, 'link' => URL::asset($destinationPath . $fileName), 'short_link' => $destinationPath . $fileName, 'delimiter' => ',');
     return $response;
 }
Exemple #13
0
 public function uploadFiles($idPaciente, $img_profile)
 {
     $fileSystem = new Filesystem();
     $countProfileImg = count($img_profile);
     //creo la extructura de carpetas para el doctor
     //for profile_img
     if (!empty($img_profile)) {
         $destinationPath = public_path() . "/upload/hospitales/FACHADASG/FACHADASCH/";
         $file = str_replace('data:image/png;base64,', '', $img_profile);
         $img = str_replace(' ', '+', $file);
         $data = base64_decode($img);
         $filename = date('ymdhis') . '_croppedImage' . ".png";
         $file = $destinationPath . $filename;
         $success = file_put_contents($file, $data);
         // THEN RESIZE IT
         $returnData = "upload/hospitales/FACHADASG/FACHADASCH/" . $filename;
         $image = Image::make(file_get_contents(URL::asset($returnData)));
         $image = $image->resize(300, 300)->save($destinationPath . $filename);
         if (!$success) {
             return false;
         }
     } else {
         $filename = "";
     }
     /*if($countProfileImg > 0){
           if($fileSystem->exists("upload/pacientes/$idPaciente/profile_img/")){
               $name=date('Ymdhis').'.'.$img_profile->getClientOriginalExtension();
               if(!$img_profile->move("upload/pacientes/$idPaciente/profile_img",$name)){
                   return false;
               }
           }
       }else{
           $name="";
       }*/
     return array('img_profile_name' => $filename);
 }
Exemple #14
0
 public function uploadFiles($idServicio, $img_profile)
 {
     $fileSystem = new Filesystem();
     $countProfileImg = count($img_profile);
     //creo la extructura de carpetas para el doctor
     //for profile_img
     if (!empty($img_profile)) {
         $destinationPath = public_path() . "/upload/servicio/";
         $file = str_replace('data:image/png;base64,', '', $img_profile);
         $img = str_replace(' ', '+', $file);
         $data = base64_decode($img);
         $filename = date('ymdhis') . '_croppedImage' . ".png";
         $file = $destinationPath . $filename;
         $success = file_put_contents($file, $data);
         // THEN RESIZE IT
         $returnData = "upload/servicio/" . $filename;
         $image = Image::make(file_get_contents(URL::asset($returnData)));
         $image = $image->resize(300, 300)->save($destinationPath . $filename);
         if (!$success) {
             return false;
         }
     } else {
         $filename = "";
     }
     return array('img_profile_name' => $filename);
 }
Exemple #15
0
 /**
  * Get the picture for the user.
  *
  * @param  boolean  $thumbnail
  * @return string
  */
 public function getPicture($thumbnail = false)
 {
     $picture = URL::asset('assets/images/display-pic-default.png');
     if (!$thumbnail) {
         $file = config('auth.path_picture') . config('auth.filename_picture');
     } else {
         $file = config('auth.path_picture_thumbnail') . config('auth.filename_picture_thumbnail');
     }
     $file = str_replace(':userId', $this->id, $file);
     if (is_file($file)) {
         $picture = URL::to($file);
     }
     return $picture;
 }
 /**
  * Returns a resized image url.
  * Resized on height constraint.
  *
  * @param string $url    Base url.
  * @param int    $height Height to resize to.
  *
  * @return string
  */
 public static function height($url, $height = 0)
 {
     if (empty($height) || !is_numeric($height)) {
         $height = config('image.thumbs_height');
     }
     $info = pathinfo($url);
     $cacheKey = preg_replace(['/:filename/', '/:width/', '/:height/'], [$info['filename'], '', $height], config('image.cache_key_format'));
     return Cache::remember($cacheKey, config('image.cache_minutes'), function () use($url, $height, $info) {
         $size = getimagesize($url);
         $assetPath = sprintf('%s%s_x%s.%s', Config::get('image.thumbs_folder'), $info['filename'], $height, $info['extension']);
         if (!file_exists(public_path() . $assetPath)) {
             $image = new ImageResize($url);
             $image->interlace = 1;
             $image->scale(ceil(100 + ($height - $size[1]) / $size[1] * 100));
             $image->save(public_path() . $assetPath);
         }
         return URL::asset($assetPath);
     });
 }
Exemple #17
0
 public function uploadFiles($idDoctor, $img_profile, $cv, $bannerImg)
 {
     $fileSystem = new Filesystem();
     $countProfileImg = count($img_profile);
     $countCV = count($cv);
     $countBanner = count($bannerImg);
     //creo la extructura de carpetas para el doctor
     //for profile_img
     if (!empty($img_profile)) {
         $destinationPath = public_path() . "/upload/doctores/{$idDoctor}/profile_img/";
         $file = str_replace('data:image/png;base64,', '', $img_profile);
         $img = str_replace(' ', '+', $file);
         $data = base64_decode($img);
         $filename = date('ymdhis') . '_croppedImage' . ".png";
         $file = $destinationPath . $filename;
         $success = file_put_contents($file, $data);
         // THEN RESIZE IT
         $returnData = "upload/doctores/{$idDoctor}/profile_img/" . $filename;
         $image = Image::make(file_get_contents(URL::asset($returnData)));
         $image = $image->resize(300, 300)->save($destinationPath . $filename);
         if (!$success) {
             return false;
         }
     } else {
         $filename = "";
     }
     /*if($countProfileImg > 0){
                 if($fileSystem->exists("upload/doctores/$idDoctor/profile_img/")){
                     $name=date('Ymdhis').'.'.$img_profile->getClientOriginalExtension();
     
                     if(stripos($name, '?')) {
                         $filename = explode('?', $name);
     
                         $name = $filename[0];
                     }
     
                     if(!$img_profile->move("upload/doctores/$idDoctor/profile_img",$name)){
                     if(file_put_contents($file, $data)){
                         return false;
                     }
                 }
             }else{
                 $name="";
             }*/
     //for cv
     if ($countCV > 0) {
         if ($fileSystem->exists("upload/doctores/{$idDoctor}/cv/")) {
             $nameCV = date('Ymdhis') . '.' . $cv->getClientOriginalExtension();
             if (!$cv->move("upload/doctores/{$idDoctor}/cv", $nameCV)) {
                 return false;
             }
         }
     } else {
         $nameCV = "";
     }
     //for banner_img
     if ($countBanner > 0) {
         if ($fileSystem->exists("upload/doctores/{$idDoctor}/banner_img/")) {
             $nameBanner = date('Ymdhis') . '.' . $bannerImg->getClientOriginalExtension();
             if (!$bannerImg->move("upload/doctores/{$idDoctor}/banner_img", $nameBanner)) {
                 return false;
             }
         }
     } else {
         $nameBanner = "";
     }
     return array('img_profile_name' => $filename, 'cv_name' => $nameCV, 'banner_name' => $nameBanner);
 }