app/Http/Controllers/RentController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(Request $request)
    {
        $this->validate($request, [
            'driver_id' => 'required|unique:rents,driver_id',
            'vehicle_id' => 'required|unique:rents,vehicle_id'
        ]);
        Rent::create([
            'driver_id' => $request->driver_id,
            'vehicle_id' => $request->vehicle_id
        ]);
        return redirect()->route('rent.index')->with('pesan', 'Data added successfuly!');
    }
public function store ( Request $ request ) { $ this -> validate ( $ request , [ 'driver_id' => 'required|unique:rents,driver_id' , 'vehicle_id' => 'required|unique:rents,vehicle_id' ] ) ; Rent :: create ( [ 'driver_id' => $ request -> driver_id , 'vehicle_id' => $ request -> vehicle_id ] ) ; return redirect ( ) -> route ( 'rent.index' ) -> with ( 'pesan' , 'Data added successfuly!' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .