jeudi 1 février 2018

The WHERE clause error in Laravel 5.4

I am creating a DB raw query, to return a record between two dates, but giving an error, my MYSQL look like this 2018-01-25 using the format Y-m-d

This is my query

public function index() {
        date_default_timezone_set('UTC');
        $format = 'Y/m/d';
        $now = date($format);
        $to = date($format);
        $data = [
            'from' => $now,
            'to' => $to
        ];

        $em = $this->getEm($data);
        return view('report.index', ['em' => $em, 'search' => $data]);
    }


private function getData($data) {
        return DB::table('A')     
        ->select('A.firstname', 'A.middlename', 'A.lastname')
        ->where('date_hired', '>=', $data['from'])
        ->where('date_hired', '<=', $data['to'])
        ->get()
        ->map(function ($item, $key) {
        return (array) $item;
        })
        ->all();
    }
}

The following error occurs when I run the query

 (1/1) InvalidArgumentException
Illegal operator and value combination.

The question is how to remove the error to return results, who can assist me



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2nvxxns
via IFTTT

Aucun commentaire:

Enregistrer un commentaire