lundi 3 septembre 2018

laravel validation between 2 dates

Unable to validate the variable. using this shows error undefined offset :2. I just want to validate perticular field so that both the entries are must to get the filter data.

public function TimesheetResult(Request $request){

    $datefrom= $request->input('datefrom');
    $dateto= $request->input('dateto');
    $orderfrom = explode('/',$datefrom);
    $orderto = explode('/', $dateto);
    $fromdate = $orderfrom[2]. "-" .$orderfrom[1]. "-" .$orderfrom[0];
    $todate = $orderto[2]. "-" .$orderto[1]. "-" .$orderto[0];

    $values = UserTimesheet::getDataBetweenDates($fromdate, $todate);
    $validator = Validator::make($values, [
        'fromdate'    => 'required|date',
        'todate'      => 'required|date',
    ]);


    return view('admin.timesheet-result',compact('values'));



    // print_r($value); exit;


}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire