dimanche 9 juin 2019

Laravel 5.2 Get filter date_diff (6days) of data each rows then pass it as an array

I want to filter data based on it's date_diff (6days) with status of trial = 1 for each rows then pass it as an array using eloquent method. Thanks!

Function:

public function checkTrialUser(){
$trialuser =  Staff::select(DB::raw('unix_timestamp(NOW()) - unix_timestamp(created_at) AS time_diff'))
->where('trial',1)
->get();

Log::info('this is a output',$trialuser);
}

Database table:

+------------+--------------+------+-----+---------+----------------+
| Field      | Type         | Null | Key | Default | Extra          |
+------------+--------------+------+-----+---------+----------------+
| id         | int(11)      | NO   | PRI | NULL    | auto_increment |
| first_name | varchar(255) | NO   |     | NULL    |                |
| last_name  | varchar(255) | NO   |     | NULL    |                |
| email      | varchar(255) | NO   |     | NULL    |                |
| created_at | timestamp    | YES  |     | NULL    |                |
| updated_at | timestamp    | YES  |     | NULL    |                |
| last_login | timestamp    | YES  |     | NULL    |                |
| trial      | tinyint(4)   | NO   |     | NULL    |                |
+------------+--------------+------+-----+---------+----------------+



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2I8bBup
via IFTTT

Aucun commentaire:

Enregistrer un commentaire