app/Http/Controllers/MedicineController.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)
    {
        $data = new Medicine();
        $data->name = $request->get('name');
        $data->form = $request->get('form');
        $data->restriction_formula = $request->get('formula');
        $data->description = $request->get('description');
        $data->price = $request->get('price');
        $image= $request->file('image');
        $imageName = $image->getClientOriginalName();
        $image->move('assets/images',$imageName);
        $data->image = $imageName;
        $data->faskes1 = isset($request->faskes1) ? 1:0;
        $data->faskes2 = isset($request->faskes2) ? 1:0;
        $data->faskes3 = isset($request->faskes3) ? 1:0;
        $data->category_id = $request->kategori;
        $data->idSupplier = $request->supplier;
        $data->save();
        return redirect()->route("medicines.index")->with("status", "Medicine is added!");
    }
public function store ( Request $ request ) { $ data = new Medicine ( ) ; $ data -> name = $ request -> get ( 'name' ) ; $ data -> form = $ request -> get ( 'form' ) ; $ data -> restriction_formula = $ request -> get ( 'formula' ) ; $ data -> description = $ request -> get ( 'description' ) ; $ data -> price = $ request -> get ( 'price' ) ; $ image = $ request -> file ( 'image' ) ; $ imageName = $ image -> getClientOriginalName ( ) ; $ image -> move ( 'assets/images' , $ imageName ) ; $ data -> image = $ imageName ; $ data -> faskes1 = isset ( $ request -> faskes1 ) ? 1 : 0 ; $ data -> faskes2 = isset ( $ request -> faskes2 ) ? 1 : 0 ; $ data -> faskes3 = isset ( $ request -> faskes3 ) ? 1 : 0 ; $ data -> category_id = $ request -> kategori ; $ data -> idSupplier = $ request -> supplier ; $ data -> save ( ) ; return redirect ( ) -> route ( " medicines.index " ) -> with ( " status " , " Medicine is added! " ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .