app/Http/Controllers/AdminPortofolioController.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, Portofolio $portofolio)
    {
        $rules = [
            'title' => 'required|max:255',
            'image' => 'image|file|max:2024',
            'category' => 'required',
            'description' => 'required',
            'status' => 'required',
            'url' => 'url'
        ];
        $validatedData = $request->validate($rules);
        if($request->file('image')){
            if($request->oldImage){
                Storage::delete($request->oldImage);
            }
            $validatedData['image'] = $request->file('image')->store('portofolio-image');
        }
        $validatedData['description'] = Str::limit(strip_tags($request->description), 200);
        Portofolio::where('id', $portofolio->id)
            ->update($validatedData);
        return redirect('dashboard/portofolio')->with('success', 'Edit Success');
    }
public function update ( Request $ request , Portofolio $ portofolio ) { $ rules = [ 'title' => 'required|max:255' , 'image' => 'image|file|max:2024' , 'category' => 'required' , 'description' => 'required' , 'status' => 'required' , 'url' => 'url' ] ; $ validatedData = $ request -> validate ( $ rules ) ; if ( $ request -> file ( 'image' ) ) { if ( $ request -> oldImage ) { Storage :: delete ( $ request -> oldImage ) ; } $ validatedData [ 'image' ] = $ request -> file ( 'image' ) -> store ( 'portofolio-image' ) ; } $ validatedData [ 'description' ] = Str :: limit ( strip_tags ( $ request -> description ) , 200 ) ; Portofolio :: where ( 'id' , $ portofolio -> id ) -> update ( $ validatedData ) ; return redirect ( 'dashboard/portofolio' ) -> with ( 'success' , 'Edit Success' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .