Пример #1
0
 public function add($data, $relation = null, $attach_id = null, $returnId = true)
 {
     $prefix = 'fl';
     $model = null;
     switch ($relation) {
         case 'products':
             $model = \Veer\Models\Product::find($attach_id);
             $prefix = 'prd';
             break;
         case 'pages':
             $model = \Veer\Models\Page::find($attach_id);
             $prefix = 'pg';
             break;
         case 'categories':
             $model = \Veer\Models\Category::find($attach_id);
             $prefix = 'ct';
             break;
         case 'users':
             $model = \Veer\Models\User::find($attach_id);
             $prefix = 'usr';
             break;
     }
     $id = $this->upload('image', 'uploadImage', $attach_id, $model, $prefix, null, is_object($model) ? false : true, $data);
     return $returnId ? $id : $this;
 }
Пример #2
0
 public function getCategoriesWhereHasElements($type, $id, $siteId)
 {
     return \Veer\Models\Category::whereHas($type, function ($q) use($id) {
         $q->where('elements_id', '=', $id);
     })->where('sites_id', '=', $siteId)->with(array('images' => function ($query) {
         $query->orderBy('pivot_id', 'asc');
     }))->orderBy('created_at', 'desc')->get();
 }
Пример #3
0
 /**
  * Delete Category: Category & connections
  *
  */
 protected function deleteCategory($cid)
 {
     if (empty($cid)) {
         return false;
     }
     \Veer\Models\Category::destroy($cid);
     \Veer\Models\CategoryConnect::where('categories_id', '=', $cid)->forceDelete();
     \Veer\Models\CategoryPivot::where('parent_id', '=', $cid)->orWhere('child_id', '=', $cid)->forceDelete();
     \Veer\Models\ImageConnect::where('elements_id', '=', $cid)->where('elements_type', '=', 'Veer\\Models\\Category')->forceDelete();
     // We do not delete communications for deleted items
     return true;
 }
Пример #4
0
 /**
  * Get category.
  * 
  * 
  */
 public function getCategory($id, $siteId = null)
 {
     if (!empty($siteId)) {
         return \Veer\Models\Category::where('sites_id', '=', $siteId)->where('id', '=', $id)->with(array('subcategories' => function ($query) use($siteId) {
             $query->where('sites_id', '=', $siteId);
         }, 'parentcategories' => function ($query) use($siteId) {
             $query->where('sites_id', '=', $siteId);
         }))->first();
     }
     return \Veer\Models\Category::where('id', '=', $id)->with(array('parentcategories' => function ($query) {
         $query->orderBy('manual_sort', 'asc');
     }, 'subcategories' => function ($query) {
         $query->orderBy('manual_sort', 'asc')->with('pages', 'products', 'subcategories');
     }))->first();
 }
Пример #5
0
 public function __construct()
 {
     $c = json_decode('[' . db_parameter('SIDEBAR_CATEGORIES') . ']');
     app('veer')->cachingQueries->make(\Veer\Models\Category::where('sites_id', '=', app('veer')->siteId)->where('id', '!=', db_parameter('CATEGORY_HOME', 0))->whereIn('id', $c)->orderBy('manual_sort', 'asc'));
     $this->data['categories'] = app('veer')->cachingQueries->lists('title', 'id', 5, 'categoriesSidebar' . app('veer')->siteId);
 }
Пример #6
0
 /**
  * @return mixed
  */
 protected function one()
 {
     $this->id = Input::get('category');
     $category = \Veer\Models\Category::find($this->id);
     if (!is_object($category)) {
         event('veer.message.center', trans('veeradmin.error.model.not.found'));
         return \Redirect::route('admin.show', ['categories']);
     }
     $this->entity = $category;
     $this->goThroughEverything();
     if ($this->action == 'deleteCurrent') {
         Input::replace(['category' => null]);
         app('veer')->skipShow = true;
         event('veer.message.center', trans('veeradmin.category.delete'));
         return \Redirect::route('admin.show', ['categories']);
     }
 }