app/Http/Controllers/DrugController.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)
    {
        $checkIfExist = Drug::where('name',$request->input('name'))->count();
        if ($checkIfExist == 1){
            toastr()->error('Drug Already Exist');
            return back();
        }else {
            $drug = new Drug();
            $drug->name = $request->input('name');
            $drug->drug_type_id = $request->input('type_id');
            $drug->qty_in_stock = $request->input('receiving_stock');
            $drug->unit_of_pricing = $request->input('unit_of_pricing');
            if (\Request::has('no_of_tablet')){
                $drug->no_of_tablet = $request->input('no_of_tablet');
                $drug->qty_in_tablet = $request->input('receiving_stock')*10;
            }
            $drug->retail_price = $request->input('retail_price');
            $drug->supplier_id = $request->input('supplier_id');
            $drug->cost_price = $request->input('cost_price');
            $drug->nhis_amount = $request->input('nhis_amount');
            $drug->expiry_date = str_replace('/','-',$request->input('expiry_date'));
            $drug->user_id = Auth::user()->id;
            $drug->save();
            toastr()->success('Drug Added');
            return redirect('/drugs');
        }
    }
public function store ( Request $ request ) { $ checkIfExist = Drug :: where ( 'name' , $ request -> input ( 'name' ) ) -> count ( ) ; if ( $ checkIfExist == 1 ) { toastr ( ) -> error ( 'Drug Already Exist' ) ; return back ( ) ; } else { $ drug = new Drug ( ) ; $ drug -> name = $ request -> input ( 'name' ) ; $ drug -> drug_type_id = $ request -> input ( 'type_id' ) ; $ drug -> qty_in_stock = $ request -> input ( 'receiving_stock' ) ; $ drug -> unit_of_pricing = $ request -> input ( 'unit_of_pricing' ) ; if ( \ Request :: has ( 'no_of_tablet' ) ) { $ drug -> no_of_tablet = $ request -> input ( 'no_of_tablet' ) ; $ drug -> qty_in_tablet = $ request -> input ( 'receiving_stock' ) * 10 ; } $ drug -> retail_price = $ request -> input ( 'retail_price' ) ; $ drug -> supplier_id = $ request -> input ( 'supplier_id' ) ; $ drug -> cost_price = $ request -> input ( 'cost_price' ) ; $ drug -> nhis_amount = $ request -> input ( 'nhis_amount' ) ; $ drug -> expiry_date = str_replace ( '/' , '-' , $ request -> input ( 'expiry_date' ) ) ; $ drug -> user_id = Auth :: user ( ) -> id ; $ drug -> save ( ) ; toastr ( ) -> success ( 'Drug Added' ) ; return redirect ( '/drugs' ) ; } }
Store a newly created resource in storage.
Store a newly created resource in storage .
//                $drug->no_of_tablet = $request->input('no_of_tablet');