app/Http/Controllers/StructuresController.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)
    {
        $structure = Structure::find($id);
        $this->authorize('update', $structure);
        $structure->description = $request['description'];
        $structure->experience = $request['experience'];
        $structure->save();
        if($structure)  {
            if($request['image'] != null){
                $file = $request->file('image');
                $image = $structure->id.'.'.$file->getClientOriginalExtension();
                if (!file_exists(public_path('images/structures'))) {
                    mkdir(public_path('images/structures'));
                }
                $file->move(public_path('images/structures'), $image);
                $structure->image = "images/structures/".$image;
                $structure->save();
            }
            return redirect()->route('structures.show', $id);
        }
    }
public function update ( Request $ request , $ id ) { $ structure = Structure :: find ( $ id ) ; $ this -> authorize ( 'update' , $ structure ) ; $ structure -> description = $ request [ 'description' ] ; $ structure -> experience = $ request [ 'experience' ] ; $ structure -> save ( ) ; if ( $ structure ) { if ( $ request [ 'image' ] != null ) { $ file = $ request -> file ( 'image' ) ; $ image = $ structure -> id . '.' . $ file -> getClientOriginalExtension ( ) ; if ( ! file_exists ( public_path ( 'images/structures' ) ) ) { mkdir ( public_path ( 'images/structures' ) ) ; } $ file -> move ( public_path ( 'images/structures' ) , $ image ) ; $ structure -> image = " images/structures/ " . $ image ; $ structure -> save ( ) ; } return redirect ( ) -> route ( 'structures.show' , $ id ) ; } }
Update the specified resource in storage.
Update the specified resource in storage .