app/Http/Controllers/RentController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Rent  $rent
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, Rent $rent)
    {
        $this->validate($request, [
            'driver_id' => 'required|unique:rents,driver_id,'.$rent->id,
            'vehicle_id' => 'required|unique:rents,vehicle_id,'.$rent->id
        ]);
        Rent::where('id', $rent->id)->update([
            'driver_id' => $request->driver_id,
            'vehicle_id' => $request->vehicle_id
        ]);
        return redirect()->route('rent.index')->with('pesan', 'Data updated successfuly!');
    }
public function update ( Request $ request , Rent $ rent ) { $ this -> validate ( $ request , [ 'driver_id' => 'required|unique:rents,driver_id,' . $ rent -> id , 'vehicle_id' => 'required|unique:rents,vehicle_id,' . $ rent -> id ] ) ; Rent :: where ( 'id' , $ rent -> id ) -> update ( [ 'driver_id' => $ request -> driver_id , 'vehicle_id' => $ request -> vehicle_id ] ) ; return redirect ( ) -> route ( 'rent.index' ) -> with ( 'pesan' , 'Data updated successfuly!' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .