| Total Complexity | 8 |
| Total Lines | 46 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | class EventController extends Controller |
||
| 12 | { |
||
| 13 | // |
||
| 14 | public function index() |
||
| 15 | { |
||
| 16 | $projects = Project::where('is_archived', false)->get(); |
||
| 17 | $archive = Project::where('is_archived', true)->get(); |
||
| 18 | foreach( $archive as $project ) |
||
| 19 | { |
||
| 20 | // Set the time range of the project by selecting the last and first dates of its events |
||
| 21 | // if no events are associated with the project, set the dates to '-' |
||
| 22 | $firstEvent = $project->events()->orderBy('start_date', 'ASC')->first(); |
||
| 23 | $project->start_date = $firstEvent === null ? '-' : $firstEvent->start_date; |
||
|
1 ignored issue
–
show
|
|||
| 24 | $lastEvent = $project->events()->orderBy('end_date', 'DESC')->first(); |
||
| 25 | $project->end_date = $lastEvent === null ? '-' : $lastEvent->end_date; |
||
|
1 ignored issue
–
show
|
|||
| 26 | } |
||
| 27 | |||
| 28 | $events = Event::whereHas('project', function(Builder $query) { |
||
| 29 | $query->where('is_archived', false); |
||
| 30 | })->get(); |
||
| 31 | |||
| 32 | return view('admin.events.index', [ |
||
| 33 | 'projects' => $projects, |
||
| 34 | 'events' => $events, |
||
| 35 | 'archived' => $archive |
||
| 36 | ]); |
||
| 37 | } |
||
| 38 | |||
| 39 | public function create() |
||
| 42 | } |
||
| 43 | |||
| 44 | public function get(Event $event) |
||
| 45 | { |
||
| 46 | return "TODO"; |
||
| 47 | } |
||
| 48 | |||
| 49 | public function update(Event $event) |
||
| 52 | } |
||
| 53 | |||
| 54 | public function delete(Event $event) |
||
| 57 | } |
||
| 58 | } |
||
| 59 |
Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.