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(ProductRequest $request)
    {
        $product = new Product;
        $product->name = $request->name;
        $product->price = $request->price;
        $product->stock = $request->stock;
        $product->discount = $request->discount;
        $product->details = $request->description;
        $product->save();
        return response([
            'data' => new ProductResource($product)
        ],Response::HTTP_CREATED);
    }
public function store ( ProductRequest $ request ) { $ product = new Product ; $ product -> name = $ request -> name ; $ product -> price = $ request -> price ; $ product -> stock = $ request -> stock ; $ product -> discount = $ request -> discount ; $ product -> details = $ request -> description ; $ product -> save ( ) ; return response ( [ 'data' => new ProductResource ( $ product ) ] , Response :: HTTP_CREATED ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .