recent_employees =DB::table('users.created_at')
->join('employees', 'users.id', '=', 'employees.user_id')
->select('users.id', 'name','created_at')
->where DATE_SUB(CURDATE(),INTERVAL 30 DAY) <= 'created_at';
->get();
答案 0 :(得分:0)
试试这个
recent_employees = DB :: table('users as u') - &gt; join('employees as e','users.id','=','employees.user_id')
->select('u.id', 'e.name','u.created_at')
->whereRaw('DATE_SUB(CURDATE(),INTERVAL 30 DAY) <= 'created_at')
->get();
答案 1 :(得分:0)
$date = date("Y-m-d");// current date
$dates = date("Y-m-d", strtotime(date("Y-m-d", strtotime($date)) . " -1
month"));
$count_student = DB::table('students')->count();
$recent_students =DB::table('users')
->join('students', 'users.id', '=', 'students.user_id')
/*->select('users.id', 'name','users.created_at')*/
->where('created_at', ">=", $dates)
->get();