app/Http/Controllers/MedicineController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Medicine  $medicine
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, Medicine $medicine)
    {
        $medicine->name = $request->name;
        $medicine->form = $request->form;
        $medicine->restriction_formula = $request->formula;
        $medicine->description = $request->description;
        $medicine->price = $request->price;
        $image= $request->file('image');
        if(isset($image)){
            $imageName = $image->getClientOriginalName();
            $image->move('assets/images',$imageName);
            $medicine->image = $imageName;
        }
        $medicine->faskes1 = isset($request->faskes1) ? 1:0;
        $medicine->faskes2 = isset($request->faskes2) ? 1:0;
        $medicine->faskes3 = isset($request->faskes3) ? 1:0;
        $medicine->category_id = $request->kategori;
        $medicine->idSupplier = $request->supplier;
        $medicine->save();
        return redirect()->route("medicines.index")->with("status", "Medicine is changed!");
    }
public function update ( Request $ request , Medicine $ medicine ) { $ medicine -> name = $ request -> name ; $ medicine -> form = $ request -> form ; $ medicine -> restriction_formula = $ request -> formula ; $ medicine -> description = $ request -> description ; $ medicine -> price = $ request -> price ; $ image = $ request -> file ( 'image' ) ; if ( isset ( $ image ) ) { $ imageName = $ image -> getClientOriginalName ( ) ; $ image -> move ( 'assets/images' , $ imageName ) ; $ medicine -> image = $ imageName ; } $ medicine -> faskes1 = isset ( $ request -> faskes1 ) ? 1 : 0 ; $ medicine -> faskes2 = isset ( $ request -> faskes2 ) ? 1 : 0 ; $ medicine -> faskes3 = isset ( $ request -> faskes3 ) ? 1 : 0 ; $ medicine -> category_id = $ request -> kategori ; $ medicine -> idSupplier = $ request -> supplier ; $ medicine -> save ( ) ; return redirect ( ) -> route ( " medicines.index " ) -> with ( " status " , " Medicine is changed! " ) ; }
Update the specified resource in storage.
Update the specified resource in storage .