mirror of
https://gitlab.com/TheGamecraft/c-cms.git
synced 2026-04-21 10:49:10 -04:00
April 9 update
This commit is contained in:
81
app/Http/Controllers/StatsController.php
Normal file
81
app/Http/Controllers/StatsController.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class StatsController extends Controller
|
||||
{
|
||||
public function instruction()
|
||||
{
|
||||
$instructorUTTD = collect();
|
||||
|
||||
$coursesTY = \App\Course::allThisYear();
|
||||
$nbCoursePlanDoneTY = 0;
|
||||
$nbCoursePlanDoneAndCheckTY = 0;
|
||||
foreach ($coursesTY as $course)
|
||||
{
|
||||
if ($course->lessonPlan)
|
||||
{
|
||||
if ($course->lessonPlan->approved)
|
||||
{
|
||||
$nbCoursePlanDoneAndCheckTY++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$nbCoursePlanDoneTY++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$coursesUTTD = $coursesTY;
|
||||
$nbCoursePlanDoneUTDP = 0;
|
||||
$nbCoursePlanDoneAndCheckUTDP = 0;
|
||||
|
||||
foreach ($coursesUTTD as $key => $course)
|
||||
{
|
||||
if (date('c',strtotime($course->event->date_begin)) >= date('c'))
|
||||
{
|
||||
$coursesUTTD->forget($key);
|
||||
}
|
||||
else
|
||||
{
|
||||
$instructorUTTD->push($course->instructor());
|
||||
if ($course->lessonPlan)
|
||||
{
|
||||
if ($course->lessonPlan->approved)
|
||||
{
|
||||
$nbCoursePlanDoneAndCheckUTDP++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$nbCoursePlanDoneUTDP++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$instructorUTTD = $instructorUTTD->unique();
|
||||
|
||||
$eventTY = \App\Event::allThisYear();
|
||||
$eventUTTD = $eventTY;
|
||||
foreach ($eventUTTD as $key => $event)
|
||||
{
|
||||
if (date('c',strtotime($event->date_begin)) >= date('c'))
|
||||
{
|
||||
$eventUTTD->forget($key);
|
||||
}
|
||||
}
|
||||
return view('admin.stats.instruction',[
|
||||
'nbCourseThisYear' => count($coursesTY),
|
||||
'nbInstructorUpToThisDay' => count($instructorUTTD),
|
||||
'nbEventThisYear' => count($eventTY),
|
||||
'nbEventUpToThisDay' => count($eventUTTD),
|
||||
'nbCourseUpToThisDay' => count($coursesUTTD),
|
||||
'nbCoursePlanDoneUTDP' => $nbCoursePlanDoneUTDP,
|
||||
'nbCoursePlanDoneTY' => $nbCoursePlanDoneTY,
|
||||
'nbCoursePlanDoneAndCheckUTDP' => $nbCoursePlanDoneAndCheckUTDP,
|
||||
'nbCoursePlanDoneAndCheckTY' => $nbCoursePlanDoneAndCheckTY,
|
||||
'nbCourseInDB' => count(\App\OCOM::all()),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user