Пример #1
0
 /**
  * @todo Save location by session
  *
  * @param \Illuminate\Http\Request $request
  * @param int                      $id City id
  *
  * @return Redirect
  */
 public function selectLocation($id)
 {
     $id = (int) $id;
     if (!is_null(City::find($id))) {
         Session::put(_const('SESSION_LOCATION'), $id);
         Session::save();
     }
     return redirect(route('front_home'));
 }
 /**
  * @todo Save location by session
  *
  * @param \Illuminate\Http\Request $request
  * @param int                      $id City id
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function ajaxSelectLocation(Request $request, $id)
 {
     //Only accept ajax request
     if ($request->ajax()) {
         $id = (int) $id;
         if (City::find($id) !== null) {
             //Start session if it wasn't started
             if (!$request->session()->isStarted()) {
                 $request->session()->start();
             }
             $request->session()->put(_const('SESSION_LOCATION'), $id);
             return pong(1, _t('saved_info'));
         }
     }
 }
Пример #3
0
 /**
  * Return a new simple JSON response from the application.
  *
  * @param  string $status
  * @param  string $messages
  * @param  int    $status_code
  * @param  array  $headers
  * @param  int    $options
  *
  * @return \Illuminate\Http\JsonResponse
  */
 function pong($status, $messages, $status_code = 200, array $headers = [], $options = 0)
 {
     switch ($status) {
         case 0:
             $status_text = _const('AJAX_ERROR');
             break;
         case 1:
             $status_text = _const('AJAX_OK');
             break;
         default:
             $status_text = _t('UNDEFINED');
             break;
     }
     if (is_array($messages)) {
         $data = array_merge(['status' => $status_text], $messages);
     } else {
         $data = ['status' => $status_text, 'messages' => $messages];
     }
     return response()->json($data, $status_code, $headers, $options);
 }
Пример #4
0
 /**
  * Delete product temporary images that was uploaded to temp folder
  *
  * @param Illuminate\Http\Request $request
  *
  * @return void
  */
 protected function _deleteProductTempImg($request)
 {
     $tempPath = config('front.temp_path');
     foreach ([1, 2, 3, 4] as $one) {
         $imgToDel = $request->get("product_image_{$one}");
         if ($imgToDel !== '' && check_file($tempPath . $imgToDel)) {
             foreach ($this->_productImgSizes as $size) {
                 $nameBySize = str_replace(_const('TOBEREPLACED'), "_{$size}", $imgToDel);
                 delete_file($tempPath . $nameBySize);
             }
             delete_file($tempPath . $imgToDel);
         }
     }
 }
 /**
  * Get current location (city)
  *
  * @return \App\Models\City
  */
 function current_location()
 {
     $currentId = session(_const('SESSION_LOCATION'), _const('DEFAULT_LOCATION'));
     $location = \App\Models\City::find($currentId);
     return $location;
 }
Пример #6
0
 /**
  * Avatar group to resize
  *
  * @return array
  */
 protected function _getAvatarGroup()
 {
     return ['small' => ['width' => _const('AVATAR_SMALL'), 'height' => _const('AVATAR_SMALL')]];
 }
Пример #7
0
 /**
  * cover group to resize
  *
  * @return array
  */
 protected function _getCoverGroup()
 {
     return ['big' => ['width' => _const('COVER_BIG_W'), 'height' => _const('COVER_BIG_H')], 'medium' => ['width' => _const('COVER_MEDIUM_W'), 'height' => _const('COVER_MEDIUM_H')], 'small' => ['width' => _const('COVER_SMALL_W'), 'height' => _const('COVER_SMALL_H')]];
 }