-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
53,956 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
use Illuminate\Http\Request; | ||
use LaravelLocalization; | ||
use App\Schedule; | ||
|
||
class CurrentEventController extends Controller { | ||
|
||
private $now; | ||
|
||
private function getCurr($events) { | ||
$coll = $events -> where('hour', '<=', $this->now); | ||
$last = $coll -> pop(); | ||
$prevToLast = $coll -> last(); | ||
# if there are many events happening at the exact same time, choose the one that is not a general event | ||
while(!is_null($last) && $coll -> isNotEmpty() && $last -> hour == $prevToLast -> hour) { | ||
if($last -> type != "general" && $prevToLast -> type == "general") { | ||
$coll -> pop(); | ||
$coll -> push($last); | ||
} | ||
$last = $coll -> pop(); | ||
$prevToLast = $coll -> last(); | ||
} | ||
return $last; | ||
} | ||
|
||
private function getNext($events) { | ||
$next = $events -> where('hour', '>', $this->now) -> whereIn('type', ['talk', 'performance']) -> first(); | ||
return $next; | ||
} | ||
|
||
public function __construct() { | ||
$this->now = date('H:i'); | ||
} | ||
|
||
public function index(Request $request) { | ||
|
||
if(env('SHOW_HIDDEN_ENTRIES', false) == true) { | ||
$where = []; | ||
} else { | ||
$where = [['visible', true]]; | ||
} | ||
|
||
if(date('Y-m-d') == '2018-03-24') { | ||
$events = Schedule :: where(array_merge($where, [['type', '!=', 'workshop']])) | ||
-> orderBy('hour', 'asc') | ||
-> get(); | ||
} else { | ||
$events = collect([]); | ||
} | ||
|
||
$curr = $this->getCurr($events); | ||
$next = $this->getNext($events); | ||
return view('api/currentEvent', compact('curr', 'next')); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.