app/Http/Controllers/SolarPanelController.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)
    {
        $solarPanel = $this->solarPanelRepository->getById($id);
        if($solarPanel==null){
            return response()->json(
                [
                    'message' => 'solarPanel not found',
                ], 404);
        }
        $validator = Validator::make($request->all(),  [
            'model' => 'required|max:100',
            'price'=>'required|numeric',
            'manufactured_date'=>'date'
        ]);
        if ($validator->fails()) {
            return response()->json($validator->errors(), 400);
        }
        $inputs = [
            'name' => $request->input('name'),
        ];
        return $this->solarPanelRepository->update($id, $inputs);
    }
public function update ( Request $ request , $ id ) { $ solarPanel = $ this -> solarPanelRepository -> getById ( $ id ) ; if ( $ solarPanel == null ) { return response ( ) -> json ( [ 'message' => 'solarPanel not found' , ] , 404 ) ; } $ validator = Validator :: make ( $ request -> all ( ) , [ 'model' => 'required|max:100' , 'price' => 'required|numeric' , 'manufactured_date' => 'date' ] ) ; if ( $ validator -> fails ( ) ) { return response ( ) -> json ( $ validator -> errors ( ) , 400 ) ; } $ inputs = [ 'name' => $ request -> input ( 'name' ) , ] ; return $ this -> solarPanelRepository -> update ( $ id , $ inputs ) ; }
Update the specified resource in storage.
Update the specified resource in storage .