Esempio n. 1
0
 /**
  * 
  */
 protected function getConfigurationOrComponent($type = 'configuration', $siteId = null, $orderBy = array('id', 'desc'))
 {
     $orderBy = $this->replaceSortingBy($orderBy);
     if (empty($siteId)) {
         $items = \Veer\Models\Site::select();
     } else {
         $items = \Veer\Models\Site::where('id', '=', $siteId);
     }
     $items = $items->with(array($type => function ($query) use($orderBy, $type) {
         if ($type == 'components') {
             $query->orderBy('sites_id');
         }
         $query->orderBy('theme', 'asc')->orderBy($orderBy[0], $orderBy[1]);
     }))->get();
     return $items;
 }
Esempio n. 2
0
 protected function iterateThroughSites($data, $turnOff = null, $turnOn = null, $current = null, $updateSnapshots = false)
 {
     $ids = [];
     foreach ($data as $key => $values) {
         $values['url'] = trim($values['url']);
         if (empty($values['url'])) {
             continue;
         }
         $site = \Veer\Models\Site::firstOrNew(['id' => trim($key)]);
         $site->parent_id = empty($values['parent_id']) ? 0 : $values['parent_id'];
         $site->manual_sort = empty($values['manual_sort']) ? 0 : $values['manual_sort'];
         $site->on_off = !empty($site->on_off) ? true : false;
         if ($current != $key) {
             // @todo test
             $site->url = $values['url'];
             $site->redirect_on = empty($values['redirect_on']) ? 0 : true;
             $site->redirect_url = empty($values['redirect_url']) ? '' : $values['redirect_url'];
             if ($key == $turnOff) {
                 $site->on_off = false;
                 event('veer.message.center', trans('veeradmin.sites.down', ['site_id' => $site->id]));
             } elseif ($key == $turnOn) {
                 $site->on_off = true;
                 event('veer.message.center', trans('veeradmin.sites.up', ['site_id' => $site->id]));
             }
         }
         if (!isset($site->id)) {
             event('veer.message.center', trans('veeradmin.sites.new'));
         } else {
             event('veer.message.center', trans('veeradmin.sites.update'));
         }
         $site->save();
         $ids[] = $site->id;
         if ($updateSnapshots) {
             $this->refreshSiteSnapshots($site->url, $site->id);
         }
     }
     if ($current == $turnOff) {
         event('veer.message.center', trans('veeradmin.sites.error'));
     }
     \Cache::flush();
     return $ids;
 }
Esempio n. 3
0
 /**
  * Filter category by image.
  * 
  * 
  */
 protected function filterCategoryByImage($imageFilter = null, $withRelations = ['pages', 'products', 'subcategories'])
 {
     return \Veer\Models\Site::with(array('categories' => function ($query) use($imageFilter, $withRelations) {
         $query->whereHas('images', function ($q) use($imageFilter) {
             $q->where('images_id', '=', $imageFilter);
         });
         if (!empty($withRelations)) {
             $query->with($withRelations);
         }
     }));
 }
Esempio n. 4
0
 /**
  * @todo redo, remove
  * @return null | Response::view()
  */
 protected function isAjaxRequest()
 {
     if (!app('request')->ajax()) {
         return null;
     }
     $items = \Veer\Models\Site::with(['categories' => function ($query) {
         $query->has('parentcategories', '<', 1)->orderBy('manual_sort', 'asc');
     }])->orderBy('manual_sort', 'asc')->where('id', '=', Input::get('siteid', app('veer')->siteId))->get();
     /* for admin we always use 'view' instead of 'viewx' */
     return view(app('veer')->template . '.lists.categories-category', ["categories" => $items[0]->categories, "siteid" => Input::get('siteid', app('veer')->siteId)]);
 }
Esempio n. 5
0
 /**
  * Check if this site's url exists in database & return its id.
  * Because of caching turning on/off and other changes
  * come to effect after cleaning cache only.
  *
  * @param string $siteUrl
  * @return \Veer\Models\Site $siteDb
  */
 protected function isSiteAvailable($siteUrl)
 {
     $this->cachingQueries->make(\Veer\Models\Site::where('url', '=', $siteUrl)->where('on_off', '=', '1'));
     $siteDb = $this->cachingQueries->rememberForever('firstOrFail');
     if ($siteDb->redirect_on == 1 && $siteDb->redirect_url != "") {
         $siteDb = (new CachingQueries(\Veer\Models\Site::where('url', '=', $siteDb->redirect_url)->where('on_off', '=', '1')))->rememberForever('firstOrFail');
     }
     return $siteDb;
 }