app/Http/Controllers/BannerController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Banner  $banner
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, Banner $banner)
    {
        $data=request()->validate([
            'banner_header'=>'required',
            'banner_content'=>'required',
            'banner_button'=>'required',
            'carousel_icon1'=>'required',
            'carousel_icon2'=>'required',
            'banner_image'=>'required'
        ]);
        if (request('banner_image')){
            $imagePath = request('banner_image')->store('BannerImage', 'public');
            $image = Image::make("storage/{$imagePath}")->fit(1519, 389);
            $data = array_merge($data,['banner_image'=>$imagePath]);
        }
        $banner->update($data);
        return redirect('/banner');
    }
public function update ( Request $ request , Banner $ banner ) { $ data = request ( ) -> validate ( [ 'banner_header' => 'required' , 'banner_content' => 'required' , 'banner_button' => 'required' , 'carousel_icon1' => 'required' , 'carousel_icon2' => 'required' , 'banner_image' => 'required' ] ) ; if ( request ( 'banner_image' ) ) { $ imagePath = request ( 'banner_image' ) -> store ( 'BannerImage' , 'public' ) ; $ image = Image :: make ( " storage/ { $ imagePath } " ) -> fit ( 1519 , 389 ) ; $ data = array_merge ( $ data , [ 'banner_image' => $ imagePath ] ) ; } $ banner -> update ( $ data ) ; return redirect ( '/banner' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .