app/Http/Controllers/ProductController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(Request $request)
    {
        $product = $request->isMethod('put') ? Product::findOrFail($request->product_id) : new Product;
        $product->id = $request->input('product_id');
        $product->sku = $request->input('sku');
        $product->name = $request->input('name');
        $product->price = $request->input('price');
        if($product->save()){
            return new ProductResource($product);
        }
    }
public function store ( Request $ request ) { $ product = $ request -> isMethod ( 'put' ) ? Product :: findOrFail ( $ request -> product_id ) : new Product ; $ product -> id = $ request -> input ( 'product_id' ) ; $ product -> sku = $ request -> input ( 'sku' ) ; $ product -> name = $ request -> input ( 'name' ) ; $ product -> price = $ request -> input ( 'price' ) ; if ( $ product -> save ( ) ) { return new ProductResource ( $ product ) ; } }
Store a newly created resource in storage.
Store a newly created resource in storage .