예제 #1
0
 protected function saveLogo($_user_id, $_file, $_base64_data = false)
 {
     $uid = intval($_user_id);
     if ($uid <= 0) {
         xplog('Invalid user id given', __METHOD__);
         return false;
     }
     $user_company_details = $this->getDetailsByUserId($uid);
     // If logo already exists then delete the file first //
     if (!!$user_company_details && trim($user_company_details->logo) !== '') {
         if (App\Files::isFile($this->logo_dir . '/' . $user_company_details->logo)) {
             App\Cb\Files::deleteAllInstance($this->logo_dir . '/' . $user_company_details->logo);
         }
     }
     if (!$_base64_data) {
         $uploaded_image_details = App\Upload::save($_file, ['destination' => $this->logo_dir . '/']);
     } else {
         $uploaded_image_details = App\Upload::saveBase64($_file->base64, ['destination' => $this->logo_dir . '/', 'extension' => $_file->extension]);
     }
     if (!is_object($uploaded_image_details)) {
         xplog('Unable to save logo', __METHOD__);
         return false;
     }
     // Save in the database //
     $res = DB::table('user_company_details')->where('users_id', $uid)->update(['logo' => $uploaded_image_details->coded_name]);
     if ($res === false) {
         xplog('Unable to save logo in the database', __METHOD__);
         return false;
     }
     return $uploaded_image_details->coded_name;
 }
예제 #2
0
 protected function deleteAllInstance($_path)
 {
     if (!App\Files::isFile($_path)) {
         xplog('File "' . $_path . '" cannot be found while trying to delete', __METHOD__);
         return false;
     }
     App\Files::delete($_path);
     $filename = basename($_path);
     // TODO:  delete on other directories code goes here //
 }