First of all can you put your code in the ``` so everyone can actually read this: https://help.github.com/articles/basic-writing-and-formatting-syntax/#quoting-code
but try this:
$students=DB::table('students as s')
->left('student_enrollment_units_new as se', 's.id', '=', 'se.student_id','left outer')
->select(' s.id',DB::raw('count(se.id) as month,(select count(id) from student_enrollment_units_new where student_id=s.id and date between CURDATE() - INTERVAL 7 DAY AND CURDATE() and status="enrolled") as week'))
->whereBetween('se.date', [Carbon::now()->subDays(30), Carbon::now()])
->where('se.status',"enrolled")
->where('s.active',1)
->whereNull('s.deleted_at')
->groupBy('s.id')->get();
Don't forget to use
use Carbon\Carbon;