app/Http/Controllers/SliderController.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)
    {
        $this->validateWith([
            'slider_title' => 'required',
            'image' => 'required'
        ]);
        $img = $request->file('image');
        if($img){
        $ffname = 'feat-' . str_slug( $request->slider_title ) . '-' . str_random(8) . '.' . $img->getClientOriginalExtension();
        Image::make($img)->save('uploads/sliders/'. $ffname);
        }
        $slider = new Sliders;
        $slider->slider_title = $request->slider_title;
        $slider->status = $request->status;
        if($img){
            $slider->image = $ffname;
        }
        $slider->save();
        Session::flash('success', 'Succesfully Added Slider');
        return redirect()->back();
    }
public function store ( Request $ request ) { $ this -> validateWith ( [ 'slider_title' => 'required' , 'image' => 'required' ] ) ; $ img = $ request -> file ( 'image' ) ; if ( $ img ) { $ ffname = 'feat-' . str_slug ( $ request -> slider_title ) . '-' . str_random ( 8 ) . '.' . $ img -> getClientOriginalExtension ( ) ; Image :: make ( $ img ) -> save ( 'uploads/sliders/' . $ ffname ) ; } $ slider = new Sliders ; $ slider -> slider_title = $ request -> slider_title ; $ slider -> status = $ request -> status ; if ( $ img ) { $ slider -> image = $ ffname ; } $ slider -> save ( ) ; Session :: flash ( 'success' , 'Succesfully Added Slider' ) ; return redirect ( ) -> back ( ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
// Image::make($img)->resize(270, 270)->save('uploads/sliders/'. $ffname); // request()->img->move('uploads/sliders/', $ffname);