SliderViewComposer   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6
Metric Value
wmc 2
lcom 0
cbo 6
dl 0
loc 28
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A compose() 0 19 2
1
<?php
2
3
namespace WITR\ViewComposers;
4
5
use WITR\TimeSlot;
6
use WITR\Event;
7
use WITR\Schedule\WeeklySchedule;
8
use WITR\Slideshow\Slides;
9
use Carbon\Carbon;
10
use Illuminate\View\View;
11
12
class SliderViewComposer {
13
14
	/**
15
	 * Bind data to the view.
16
	 *
17
	 * @param  View  $view
18
	 * @return void
19
	 */
20
	public function compose(View $view)
21
	{
22
		$timeslots = TimeSlot::with('djForTimeslot', 'showForTimeslot')->get();
23
		$shows = WeeklySchedule::mergeFromTimeSlots($timeslots);
24
		$showSlides = $shows->getShowsForSlideshow();
25
26
		$slides = Slides::forShows($showSlides);
27
28
		$events = Event::where('type', 'SLIDER')
29
			->where('date', '>=', Carbon::today('America/New_York'))
30
			->get();
31
		
32
		if (!$events->isEmpty()) 
33
		{
34
			$slides->addEvent($events->random());
35
		}
36
37
		$view->with('slides', $slides);
38
	}
39
}