public function getImageUrl($withBaseUrl = false) { if (!$this->icon) { return NULL; } $imgDir = '/images/countries/' . $this->id; $url = $imgDir . '/' . $this->icon; return $withBaseUrl ? URL::asset($url) : $url; }
public function uploadFiles($idFr, $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/flores_regalos/{$idFr}/"; $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/flores_regalos/{$idFr}/" . $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); }