app/Http/Controllers/ServiceController.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)
    {
        try {
            $service = Service::find($id);
            $validator = $request->validate([ 
                'titre' => 'required|string|max:255|unique:services,titre,'.$service->id,
                'description' =>'required|string',
                'prix' =>'numeric|nullable', 
                'photo'=>'mimes:jpeg,bmp,png,jpg,svg|image|filled|max:2500',
            ] ); 
            $service->titre = $request->input('titre');
            $service->description = $request->input('description');
            $service->prix = $request->input('prix'); 
            if($request->hasFile('photo')){ 
            $image =  $request->file('photo')->getClientOriginalName();
                $service->photo = $request->file('photo')->storeAs('services',$image);
            }
            $service->save();
            return redirect('services')->with('success', 'Le service a été modifié avec succès!'); 
        } catch (Exception $e) {
        }
    }
public function update ( Request $ request , $ id ) { try { $ service = Service :: find ( $ id ) ; $ validator = $ request -> validate ( [ 'titre' => 'required|string|max:255|unique:services,titre,' . $ service -> id , 'description' => 'required|string' , 'prix' => 'numeric|nullable' , 'photo' => 'mimes:jpeg,bmp,png,jpg,svg|image|filled|max:2500' , ] ) ; $ service -> titre = $ request -> input ( 'titre' ) ; $ service -> description = $ request -> input ( 'description' ) ; $ service -> prix = $ request -> input ( 'prix' ) ; if ( $ request -> hasFile ( 'photo' ) ) { $ image = $ request -> file ( 'photo' ) -> getClientOriginalName ( ) ; $ service -> photo = $ request -> file ( 'photo' ) -> storeAs ( 'services' , $ image ) ; } $ service -> save ( ) ; return redirect ( 'services' ) -> with ( 'success' , 'Le service a été modifié avec succès!');  } catch ( Exception $ e ) { } }
Update the specified resource in storage.
Update the specified resource in storage .