| Conditions | 4 |
| Paths | 5 |
| Total Lines | 22 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 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 | ]); |
||
| 59 |
Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.