app/Http/Controllers/AdController.php
/**
     * Update the specified ad in storage.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  \App\Ad $ad
     * @return \Illuminate\Http\Response
     */
Update the specified ad in storage.
Update the specified ad in storage .
public function update(Request $request, Ad $ad)
    {
        $request->validate([
            'title' => 'required',
            'description' => 'required',
            'license_plate' => 'required',
            'brand' => 'required',
            'doors' => 'required|numeric',
            'manufacture_year' => 'required|numeric',
            'apk_expiry_year' => 'digits:4',
            'apk_expiry_month' => 'digits:2',
            'apk_expiry_day' => 'digits:2',
            'price' => 'required|numeric',
            'mileage' => 'required|numeric',
            'fuel_type_id' => 'required|numeric',
            'transmission_type_id' => 'required|numeric'
        ]);
        if ($request->editPhotos) {
            foreach ($request->editPhotos as $photo) {
                $filename = $photo->store('photos', ['disk' => 'public']);
                dump($filename);
                Image::create([
                    'ad_id' => $ad->id,
                    'filename' => $filename
                ]);
            }
        }
        $ad->update($request->all());
        return redirect()->route('ads.index')
            ->with('success', 'Advertentie succesvol aangepast!');
    }
public function update ( Request $ request , Ad $ ad ) { $ request -> validate ( [ 'title' => 'required' , 'description' => 'required' , 'license_plate' => 'required' , 'brand' => 'required' , 'doors' => 'required|numeric' , 'manufacture_year' => 'required|numeric' , 'apk_expiry_year' => 'digits:4' , 'apk_expiry_month' => 'digits:2' , 'apk_expiry_day' => 'digits:2' , 'price' => 'required|numeric' , 'mileage' => 'required|numeric' , 'fuel_type_id' => 'required|numeric' , 'transmission_type_id' => 'required|numeric' ] ) ; if ( $ request -> editPhotos ) { foreach ( $ request -> editPhotos as $ photo ) { $ filename = $ photo -> store ( 'photos' , [ 'disk' => 'public' ] ) ; dump ( $ filename ) ; Image :: create ( [ 'ad_id' => $ ad -> id , 'filename' => $ filename ] ) ; } } $ ad -> update ( $ request -> all ( ) ) ; return redirect ( ) -> route ( 'ads.index' ) -> with ( 'success' , 'Advertentie succesvol aangepast!' ) ; }
Update the specified ad in storage.
Update the specified ad in storage .