app/Http/Controllers/Product/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)
    {
        $user_id = Auth::user()->id;
        $this->validate($request,[
            'product_name' => 'required',
            'sell_price' => 'required',
        ]);
        $current = new Carbon();
        $crdate =  $current->format('Y-m-d');
        $data = new Product();
        $data->product_name=$request->product_name;
        $data->product_details=$request->product_details;
        $data->buy_price=$request->buy_price;
        $data->sell_price=$request->sell_price;
        $data->warranty=$request->warranty;
        $data->purchase_date= $crdate;
        $data->user_id=$user_id;
        $data->investment_no=0;
        $data->member_id=0;
        $data->save();
        $cash = new Cash();
        $cash->date = date('Y-m-d',time());
        $cash->description = 'Investment Purpose Product Buy : '. $request->product_name;
        $cash->cr = number_format($request->buy_price,'2','.','');
        $cash->save();
        $notification = array(
            'message' => 'Product Added successfully!',
            'alert-type' => 'success'
        );
        return back()->with($notification);
    }
public function store ( Request $ request ) { $ user_id = Auth :: user ( ) -> id ; $ this -> validate ( $ request , [ 'product_name' => 'required' , 'sell_price' => 'required' , ] ) ; $ current = new Carbon ( ) ; $ crdate = $ current -> format ( 'Y-m-d' ) ; $ data = new Product ( ) ; $ data -> product_name = $ request -> product_name ; $ data -> product_details = $ request -> product_details ; $ data -> buy_price = $ request -> buy_price ; $ data -> sell_price = $ request -> sell_price ; $ data -> warranty = $ request -> warranty ; $ data -> purchase_date = $ crdate ; $ data -> user_id = $ user_id ; $ data -> investment_no = 0 ; $ data -> member_id = 0 ; $ data -> save ( ) ; $ cash = new Cash ( ) ; $ cash -> date = date ( 'Y-m-d' , time ( ) ) ; $ cash -> description = 'Investment Purpose Product Buy : ' . $ request -> product_name ; $ cash -> cr = number_format ( $ request -> buy_price , '2' , '.' , '' ) ; $ cash -> save ( ) ; $ notification = array ( 'message' => 'Product Added successfully!' , 'alert-type' => 'success' ) ; return back ( ) -> with ( $ notification ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .