Esempio n. 1
0
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create()
 {
     $CategoryDatas = new CategoryData();
     $languages = AppLanguage::orderBy('id')->get();
     $listcategories = Category::with(['CategoryData' => function ($query) {
         $query->where('language_code', '=', AppLanguage::getDefaultLanguage());
     }])->where('parent_id', '=', 0)->get();
     return view('admin.article.newcategory', compact('languages', 'listcategories', 'CategoryDatas'));
 }
Esempio n. 2
0
 /**
  * Get the option select category.
  *
  * @return String option format for select box
  */
 public function selectBoxCategory($parent_id = 0, $split = '', $select_id = '')
 {
     $str_return = '';
     $list_category = Category::with(['CategoryData' => function ($query) {
         $query->where('language_code', '=', AppLanguage::getDefaultLanguage());
     }])->where('parent_id', '=', $parent_id)->get();
     if ($list_category) {
         foreach ($list_category as $category) {
             foreach ($category->categoryData as $cate) {
                 $category_id = $category->id;
                 if ($category_id == $select_id) {
                     $attribute_option = 'selected';
                 } else {
                     $attribute_option = '';
                 }
                 $str_return .= "<option value='" . $cate->category_blogs_id . "' " . $attribute_option . '>' . $split . $cate->category_name . '</option>';
             }
             $str_return .= self::selectBoxCategory($category_id, '|---', $select_id);
         }
     }
     return $str_return;
 }