public function subcategories($categoryId)
 {
     if (isset($categoryId)) {
         $category = Category::find($categoryId);
         if (isset($category)) {
             $subcategories = SubCategory::where('status', 'active')->where('category_id', $categoryId)->get();
             if (isset($subcategories) && count($subcategories) > 0) {
                 return json_encode(array('message' => 'found', 'subcategories' => $subcategories->toArray()));
             } else {
                 return json_encode(array('message' => 'empty'));
             }
         } else {
             return json_encode(array('message' => 'invalid'));
         }
     } else {
         return json_encode(array('message' => 'invalid'));
     }
 }
示例#2
0
 public function listSubCategories($id)
 {
     $adminId = Session::get('admin_id');
     if (!isset($adminId)) {
         return json_encode(array('message' => 'not logged'));
     }
     $subCategories = SubCategory::where('category_id', '=', $id)->where('status', '=', 'active')->get();
     if (isset($subCategories) && count($subCategories) > 0) {
         return json_encode(array('message' => 'found', 'subcategories' => $subCategories->toArray()));
     } else {
         return json_encode(array('message' => 'empty'));
     }
 }
 /**
  * Get photo sub category list rendering photo sub categories.
  *
  * @return void
  */
 public function getSubCategoryList($categoryCode)
 {
     global $data;
     global $settings;
     $thisCategoryId = $data['categories'][$categoryCode]['id'];
     $thisSubCategories = $data['categories'][$categoryCode]['settings']['sub_categories'];
     $stmt = SubCategory::where('category_id', '=', $thisCategoryId);
     $stmt->whereIn('code', $thisSubCategories);
     $stmt->orderBy(DB::raw("FIELD(code, '" . implode("','", $thisSubCategories) . "')"));
     $result = $stmt->get()->keyBy('code')->toArray();
     return $result;
 }