app/Http/Controllers/Backend/BannerController.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(BannerUpdateRequest $request, Banner $banner)
    {
          if((is_null($request->image)&& is_null($request->video))||(!empty($request->image)&&!empty($request->video)))
        {
            return back()->with('error','Please insert atleast 1 file!');
        }
        else
        {
        $all =($request->all());
        $all['image'] = (new SimpleUpload)
            ->file($request->image)
            ->dirName('banners')
            ->save();
        $all = $banner->update($all);
        return back()->with('message', 'Banner Update Successfully!');
        }
    }
public function update ( BannerUpdateRequest $ request , Banner $ banner ) { if ( ( is_null ( $ request -> image ) && is_null ( $ request -> video ) ) || ( ! empty ( $ request -> image ) && ! empty ( $ request -> video ) ) ) { return back ( ) -> with ( 'error' , 'Please insert atleast 1 file!' ) ; } else { $ all = ( $ request -> all ( ) ) ; $ all [ 'image' ] = ( new SimpleUpload ) -> file ( $ request -> image ) -> dirName ( 'banners' ) -> save ( ) ; $ all = $ banner -> update ( $ all ) ; return back ( ) -> with ( 'message' , 'Banner Update Successfully!' ) ; } }
Update the specified resource in storage.
Update the specified resource in storage .
// $all = $request->all(); // // dd($all); // $all['image'] = (new SimpleUpload) //     ->file($request->image) //     ->dirName('banners') //     ->deleteIfExists($banner->image) //     ->save(); // $all = $banner->update($all); // // dd($all); // return back()->with('message', 'Banner Update Successfully!'); // Banner::update($all);