示例#1
0
 public function validateAdd($data)
 {
     if (Auth::user()->tickets()->count() > 0) {
         $t = Auth::user()->tickets()->order_by('created_at', 'DESC')->first();
         if (strtotime($t->created_at) > time() - 3600) {
             return View::make('msg.error')->with('error', 'You can only make one ticket per hour.');
         }
     }
     $rules = array('title' => 'required|min:10|max:60', 'message' => 'required|min:30|max:1000');
     $messages = array('title_min' => 'Please explain your subject a little more in the subject field', 'message_min' => 'Please explain in at least 30 characters your question', 'message_max' => 'Please explain your question in less than 1000 characters');
     $validator = Validator::make($data, $rules, $messages);
     if ($validator->fails()) {
         $errors = $validator->errors->all();
         $error_str = '';
         foreach ($errors as $e) {
             $error_str .= $e . '<br />';
         }
         return View::make('msg.error')->with('error', $error_str);
     }
     $data['user_id'] = Auth::user()->id;
     $data['ip'] = $_SERVER['REMOTE_ADDR'];
     $data['solved'] = false;
     self::create($data);
     return \Laravel\Redirect::to('/support');
 }
示例#2
0
文件: Page.php 项目: juaniiie/mwi
 public function render($slug = null, $check_restrictions = true)
 {
     if ($slug == null) {
         $slug = $this->page_slug;
     }
     if ($slug == '/' or empty($slug)) {
         $slug = 'home';
     }
     if ($slug == '404') {
         //page not found. Do we have a 404 page? really? :)
         $page = Model\Page::where('slug', '=', '404')->first();
         if (isset($page) and count($page) > 0) {
             $this->data['meta_title'] = $page->title;
             $this->data['meta_description'] = $page->meta_description;
             $this->data['meta_keywords'] = $page->meta_keywords;
             $this->data['page_content'] = $page->body;
             return $this->theme->render('pages::frontend.page', $this->data);
         } else {
             // How embarrassing we dont have a 404 page :)
             // Return default framework 404
             return Response::error('404');
         }
     }
     $page = Model\Page::where('slug', '=', $slug)->first();
     if (!isset($page) or empty($page)) {
         $page = Model\Page::where('slug', '=', '404')->first();
     }
     $page_access = explode(',', $page->restricted_to);
     if (Restriction::passes($page_access, new Auth())) {
         if (isset($page) and count($page) > 0) {
             $this->data['meta_title'] = $page->title;
             $this->data['meta_description'] = $page->meta_description;
             $this->data['meta_keywords'] = $page->meta_keywords;
             $this->data['page_content'] = $page->body;
             return $this->theme->render('pages::frontend.page', $this->data);
         } else {
             //page not found. Do we have a 404 page? really? :)
             $page = Model\Page::where('slug', '=', '404')->first();
             if (isset($page) and count($page) > 0) {
                 return Redirect::to('404');
             } else {
                 // How embarrassing we dont have a 404 page :)
                 // Return default framework 404
                 return Response::error('404');
             }
         }
     } else {
         // not allowed to view page
         //page not found. Do we have a 404 page? really? :)
         $page = Model\Page::where('slug', '=', '404')->first();
         if (isset($page) and count($page) > 0) {
             return Redirect::to('404');
         } else {
             // How embarrassing we dont have a 404 page :)
             // Return default framework 404
             return Response::error('404');
         }
     }
 }
示例#3
0
 public function post_skype()
 {
     $skype = Input::get('api');
     $skype = trim($skype);
     $settings = IniHandle::readini();
     $settings['skypeapi'] = $skype;
     IniHandle::write_ini_file($settings);
     return \Laravel\Redirect::to('/admin/booter/skype');
 }
示例#4
0
 public function get_index($alias)
 {
     //We need Category ID for grabbing products
     $category_id = CategoryDescription::with('getCategory')->where('alias', '=', $alias)->only('id');
     if ($category_id == null) {
         return \Laravel\Redirect::to('/');
     }
     //getting the products which belongs to this category!
     $data = Input::all();
     //Category attrs for filters.
     $catAttr = Category::with(array("getAttributeListing", "getAttributeListing.getAttributes"))->where('id', '=', $category_id)->first();
     $filter = array();
     if (isset($data['Filter'])) {
         foreach ($data['Filter'] as $cLine) {
             $kvp = explode('[-]', $cLine);
             // [0] = Enerji Sınıfı , [1] = A++
             $groupID = 0;
             $attrID = 0;
             foreach ($catAttr->getAttributeListing as $item) {
                 if ($kvp[0] === $item->name) {
                     $groupID = $item->id;
                     foreach ($item->getAttributes as $item2) {
                         if ($kvp[1] === $item2->value) {
                             $attrID = $item2->id;
                             $filter[$kvp[0]] = array("val" => $kvp[1], "id" => $attrID, 'GID' => $groupID);
                         }
                     }
                 }
             }
         }
     }
     $price_range = array();
     if (isset($data['Price_Range'])) {
         $price_range = explode(' - ', $data['Price_Range']);
         if ($price_range[0] == "2500TL ve üzeri") {
             $price_range[0] = 2500;
             $price_range[1] = 999999;
         }
     }
     $countforCache = Category::with('getProducts')->where('id', '=', $category_id)->first()->getProducts()->count();
     if (Cache::has('category.products.' . $category_id)) {
         $a = Cache::get('category.products.' . $category_id);
         $a = count($a->getProducts);
         if ($a !== $countforCache) {
             Cache::forget('category.products.' . $category_id);
         }
     }
     if (!Cache::has('category.products.' . $category_id)) {
         $result = Category::with(array("getProducts", "getProducts.getDetail", "getProducts.getBrand", "getProducts.getImages", "getProducts.getTax", "getProducts.getDiscount", "getProducts.getAttributes", "getChildren", "getChildren.getDescriptions", "getChildren.getProducts", "getSlideshow", "getSlideshow.getItems", "getAttributeListing", "getAttributeListing.getAttributes", "getAttributeListing.getAttributes.productSpecific"))->where('id', '=', $category_id)->first();
         Cache::forever('category.products.' . $category_id, $result, 3);
     }
     $result = Cache::get('category.products.' . $category_id);
     $products = array();
     $attributes = array();
     $brands = array();
     $price = array();
     $range = array();
     if (isset($filter)) {
         foreach ($result->getProducts as $product) {
             $mami = array();
             $prodPrice = getItemPrice($product)->tax_raw;
             foreach ($product->getAttributes as $mam) {
                 $mami[] = $mam->id;
             }
             $invalid = FALSE;
             foreach ($filter as $filtresingle) {
                 if (array_search($filtresingle['id'], $mami) === FALSE) {
                     $invalid = TRUE;
                     break;
                 }
             }
             if ($invalid == FALSE) {
                 //check for price range!
                 if (!empty($price_range)) {
                     if ($prodPrice > $price_range[0] && $prodPrice <= $price_range[1]) {
                         $brands[] = $product->getBrand->name;
                         $price[] = getItemPrice($product)->tax_raw;
                         foreach ($product->getAttributes as $attribute) {
                             array_push($attributes, $attribute->id);
                         }
                         array_push($products, $product);
                     }
                 } else {
                     $brands[] = $product->getBrand->name;
                     $price[] = getItemPrice($product)->tax_raw;
                     foreach ($product->getAttributes as $attribute) {
                         array_push($attributes, $attribute->id);
                     }
                     array_push($products, $product);
                 }
             } else {
             }
         }
     }
     if ($price != null) {
         $price = PriceRange::create($price);
     }
     if ($brands != null) {
         $brands = array_unique($brands);
     }
     $attributes = array_count_values($attributes);
     $attrgroup = array();
     foreach ($result->getAttributeListing as $groups) {
         foreach ($groups->getAttributes as $attr) {
             if (array_key_exists($attr->id, $attributes)) {
                 array_push($attrgroup, $groups->id);
             }
         }
     }
     Title::put($result->getDescriptions->name . ' Kategorisi');
     return View::make('category.index')->with('result', $result)->with('brands', $brands)->with('products', $products)->with('filters', $filter)->with('attribute_filter', $attributes)->with('ranges', $price)->with('selected_ranges', $price_range);
 }
示例#5
0
 public function get_index()
 {
     return \Laravel\Redirect::to('/');
 }
示例#6
0
 private function _validate_request($type)
 {
     // A hook before we go any further.
     if (method_exists($this, '_before_validation')) {
         $this->_before_validation();
     }
     // Set rules.
     if ($type == 'create') {
         $rules = $this->rules_create;
     } else {
         $rules = $this->rules_update;
     }
     // If we have rules we validate.
     if (is_array($rules) && count($rules > 0)) {
         // Time to validate.
         $validation = Validator::make(Input::get(), $rules, $this->rules_message);
         if ($validation->fails()) {
             if (Input::get('redirect_fail')) {
                 return Redirect::to(Input::get('redirect_fail'))->with_errors($validation)->with('data', Input::get());
             } else {
                 return $this->api_response(null, 0, $validation->errors->messages);
             }
         }
     }
     return false;
 }