Support the ongoing development of Laravel.io →
posted 10 years ago
Database
Last updated 2 years ago.
0

I got it sorted. I had tunnel vision and was forgetting basic php and variable scope.

    public function ShowCurrentRecentBreaks() {

    $thestime = date("Y-m-d H:i:s");
    $five = date("Y-m-d H:i:s",strtotime("-5 minutes",strtotime($thestime)));
    
    $result = DB::table('breaks')
            ->join('users', function($join) use ($five){
                $join->on('users.id', '=', 'breaks.user_id')
                ->where('breaks.break_end', '=', '0000-00-00 00:00:00')
                ->orWhere('breaks.break_end', '>=', $five);
            })
            ->select('users.id', 'users.username', 'breaks.user_level', 'breaks.break_type', 'breaks.break_start', 'breaks.break_end')
            ->get();

    return $result;
}
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

will35010 will35010 Joined 11 May 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.