app/Http/Controllers/AdminHomepageController.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)
    {
        $input = $request->all();
        if($file = $request->file('main_photo_id')){
            $name = 'hero-bg.jpg';
            $file->move('images', $name);
            $photo = Photo::create(['file'=>$name]);
            $input['main_photo_id'] = $photo->id;
        }
        if($file = $request->file('background_top_photo_id')){
            $name = 'about-bg.jpg';
            $file->move('images', $name);
            $photo = Photo::create(['file'=>$name]);
            $input['background_top_photo_id'] = $photo->id;
        }
        if($file = $request->file('background_bottom_photo_id')){
            $name = 'events-bg.jpg';
            $file->move('images', $name);
            $photo = Photo::create(['file'=>$name]);
            $input['background_bottom_photo_id'] = $photo->id;
        }
        if($file = $request->file('big_login_photo_id')){
            $name = 'login.jpg';
            $file->move('images', $name);
            $photo = Photo::create(['file'=>$name]);
            $input['big_login_photo_id'] = $photo->id;
        }
        if($file = $request->file('small_login_photo_id')){
            $name = 'logo.jpg';
            $file->move('images', $name);
            $photo = Photo::create(['file'=>$name]);
            $input['small_login_photo_id'] = $photo->id;
        }
        Homepage::findOrFail($id)->update($input);
        return redirect('/admin/homepages');
    }
public function update ( Request $ request , $ id ) { $ input = $ request -> all ( ) ; if ( $ file = $ request -> file ( 'main_photo_id' ) ) { $ name = 'hero-bg.jpg' ; $ file -> move ( 'images' , $ name ) ; $ photo = Photo :: create ( [ 'file' => $ name ] ) ; $ input [ 'main_photo_id' ] = $ photo -> id ; } if ( $ file = $ request -> file ( 'background_top_photo_id' ) ) { $ name = 'about-bg.jpg' ; $ file -> move ( 'images' , $ name ) ; $ photo = Photo :: create ( [ 'file' => $ name ] ) ; $ input [ 'background_top_photo_id' ] = $ photo -> id ; } if ( $ file = $ request -> file ( 'background_bottom_photo_id' ) ) { $ name = 'events-bg.jpg' ; $ file -> move ( 'images' , $ name ) ; $ photo = Photo :: create ( [ 'file' => $ name ] ) ; $ input [ 'background_bottom_photo_id' ] = $ photo -> id ; } if ( $ file = $ request -> file ( 'big_login_photo_id' ) ) { $ name = 'login.jpg' ; $ file -> move ( 'images' , $ name ) ; $ photo = Photo :: create ( [ 'file' => $ name ] ) ; $ input [ 'big_login_photo_id' ] = $ photo -> id ; } if ( $ file = $ request -> file ( 'small_login_photo_id' ) ) { $ name = 'logo.jpg' ; $ file -> move ( 'images' , $ name ) ; $ photo = Photo :: create ( [ 'file' => $ name ] ) ; $ input [ 'small_login_photo_id' ] = $ photo -> id ; } Homepage :: findOrFail ( $ id ) -> update ( $ input ) ; return redirect ( '/admin/homepages' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .
//