Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

academico-sis/academico

338 stars
2 code files
View academico-sis/academico on GitHub

app/Traits/PeriodSelection.php

Open in GitHub
use App\Models\Period;
use Illuminate\Http\Request;
 
trait PeriodSelection
{
public $currentPeriod;
 
public function __construct()
{
if (Period::count() > 0) {
$this->currentPeriod = Period::get_default_period()->id;
}
}
 
protected function selectPeriod(Request $request)
{
$period_id = $request->query('period', null);
if ($period_id == null) {
$period = Period::get_default_period();
} else {
$period = Period::find($period_id);
}
 
return $period;
}
}

app/Http/Controllers/HomeController.php

Open in GitHub
use App\Traits\PeriodSelection;
use Illuminate\Http\Request;
 
class HomeController extends Controller
{
use PeriodSelection;
 
//
public function teacher(Request $request)
{
if (! backpack_user()->isTeacher()) {
abort(403);
}
 
$period = $this->selectPeriod($request);
 
$teacher = Teacher::where('id', backpack_user()->id)->first();
Log::info($teacher->name.' accessed the student dashboard');
 
$remoteVolume = $teacher->courses()->whereNull('parent_course_id')->where('period_id', $period->id)->sum('remote_volume');
$presentialVolume = $teacher->courses()->whereNull('parent_course_id')->where('period_id', $period->id)->sum('volume');
return view('teacher.dashboard', [
'teacher' => $teacher,
'courses' => $teacher->period_courses($period),
'pending_attendance' => $teacher->events_with_pending_attendance($period),
'selected_period' => $period,
'remoteVolume' => $remoteVolume,
'volume' => $presentialVolume,
'totalVolume' => $remoteVolume + $presentialVolume,
]);
}
//
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.