app/Http/Controllers/ProductController.php
/**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
Show the form for creating a new resource.
@return \Illuminate\Http\Response
Show the form for creating a new resource . @return \ Illuminate \ Http \ Response
public function create()
    {
        $categories =Category::select('id', 'category_name')->get();
        $subcategories = '';
        if(!empty($_GET['category_id'])){
            $subcategories =SubCategory::where('category_id', '=', $_GET['category_id'])->select('id', 'sub_category_name')->get();
            return $subcategories;
        }
        return view('products.create', compact('categories', 'subcategories'));
    }
public function create ( ) { $ categories = Category :: select ( 'id' , 'category_name' ) -> get ( ) ; $ subcategories = '' ; if ( ! empty ( $ _GET [ 'category_id' ] ) ) { $ subcategories = SubCategory :: where ( 'category_id' , '=' , $ _GET [ 'category_id' ] ) -> select ( 'id' , 'sub_category_name' ) -> get ( ) ; return $ subcategories ; } return view ( 'products.create' , compact ( 'categories' , 'subcategories' ) ) ; }
Show the form for creating a new resource.
Show the form for creating a new resource .