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