app/Http/Controllers/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(Request $request, $id)
    {
        $banner=Banner::findOrFail($id);
        $this->validate($request,[
            'title'=>'string|required|max:50',
            'description'=>'string|nullable',
            'photo'=>'string|required',
            'status'=>'required|in:active,inactive',
        ]);
        $data=$request->all();
        $status=$banner->fill($data)->save();
        if($status){
            request()->session()->flash('success','Banner successfully updated');
        }
        else{
            request()->session()->flash('error','Error occurred while updating banner');
        }
        return redirect()->route('banner.index');
    }
public function update ( Request $ request , $ id ) { $ banner = Banner :: findOrFail ( $ id ) ; $ this -> validate ( $ request , [ 'title' => 'string|required|max:50' , 'description' => 'string|nullable' , 'photo' => 'string|required' , 'status' => 'required|in:active,inactive' , ] ) ; $ data = $ request -> all ( ) ; $ status = $ banner -> fill ( $ data ) -> save ( ) ; if ( $ status ) { request ( ) -> session ( ) -> flash ( 'success' , 'Banner successfully updated' ) ; } else { request ( ) -> session ( ) -> flash ( 'error' , 'Error occurred while updating banner' ) ; } return redirect ( ) -> route ( 'banner.index' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .
// $slug=Str::slug($request->title); // $count=Banner::where('slug',$slug)->count(); // if($count>0){ //     $slug=$slug.'-'.date('ymdis').'-'.rand(0,999); // } // $data['slug']=$slug; // return $slug;