<?php

namespace App\Http\Controllers\ParentPortal\Concerns;

use App\Models\Student;
use App\Services\School\ParentScopeService;
use Illuminate\Support\Collection;

trait ResolvesParentScope
{
    protected function parentScope(): ParentScopeService
    {
        return app(ParentScopeService::class);
    }

    /**
     * @return Collection<int, Student>
     */
    protected function guardianStudents(): Collection
    {
        return $this->parentScope()->linkedStudents();
    }

    protected function authorizeStudent(Student $student): void
    {
        $this->parentScope()->authorizeStudent($student);
    }

    protected function activeStudentId(): ?int
    {
        return $this->parentScope()->activeStudentId();
    }

    protected function activeStudent(): ?Student
    {
        return $this->parentScope()->activeStudent();
    }
}
