app/Http/Controllers/SliderController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, $id)
    {
        $slider = Slider::find($id);
        if ($request->hasFile('image')) {
            $file = $request->file('image');
            $extension = $file->getClientOriginalExtension();
            $filename = 'images/sliders/' . time() . '.' . $extension;
            $file->move('public/images/sliders', $filename);
            $update_slider = array(
                'title' => $request->title,
                'image' => $filename,
                'type' => $request->type,
                'expires_on' => $request->expires_on,
                'status' => $request->status
            );
        } else {
            $update_slider = array(
                'title' => $request->title,
                'type' => $request->type,
                'expires_on' => $request->expires_on,
                'status' => $request->status
            );
        }
        $slider->update($update_slider);
        return redirect('admin/sliders');
    }
public function update ( Request $ request , $ id ) { $ slider = Slider :: find ( $ id ) ; if ( $ request -> hasFile ( 'image' ) ) { $ file = $ request -> file ( 'image' ) ; $ extension = $ file -> getClientOriginalExtension ( ) ; $ filename = 'images/sliders/' . time ( ) . '.' . $ extension ; $ file -> move ( 'public/images/sliders' , $ filename ) ; $ update_slider = array ( 'title' => $ request -> title , 'image' => $ filename , 'type' => $ request -> type , 'expires_on' => $ request -> expires_on , 'status' => $ request -> status ) ; } else { $ update_slider = array ( 'title' => $ request -> title , 'type' => $ request -> type , 'expires_on' => $ request -> expires_on , 'status' => $ request -> status ) ; } $ slider -> update ( $ update_slider ) ; return redirect ( 'admin/sliders' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .