|
|
@@ -3,6 +3,7 @@
|
|
|
namespace App\Services;
|
|
|
|
|
|
use App\Models\Student;
|
|
|
+use App\Models\StudentContract;
|
|
|
use App\Models\User;
|
|
|
use Illuminate\Database\Eloquent\Collection;
|
|
|
use Illuminate\Http\UploadedFile;
|
|
|
@@ -19,6 +20,43 @@ public function getAll(User $user): Collection
|
|
|
->get();
|
|
|
}
|
|
|
|
|
|
+ public function getFranchisorActive(): Collection
|
|
|
+ {
|
|
|
+ return Student::with('unit')
|
|
|
+ ->where('status', 'active')
|
|
|
+ ->orderBy('name')
|
|
|
+ ->get();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getFranchisorStudentDetail(int $id): ?array
|
|
|
+ {
|
|
|
+ $student = Student::with('unit')->find($id);
|
|
|
+
|
|
|
+ if (!$student) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ $contract = StudentContract::where('student_id', $id)
|
|
|
+ ->where('status', 'active')
|
|
|
+ ->first();
|
|
|
+
|
|
|
+ return [
|
|
|
+ 'id' => $student->id,
|
|
|
+ 'name' => $student->name,
|
|
|
+ 'phone' => $student->phone,
|
|
|
+ 'unit' => $student->unit ? ['fantasy_name' => $student->unit->fantasy_name] : null,
|
|
|
+ 'protocol' => $contract?->protocol,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getFranchisorSummary(): array
|
|
|
+ {
|
|
|
+ $total = Student::count();
|
|
|
+ $active = Student::where('status', 'active')->count();
|
|
|
+
|
|
|
+ return ['total' => $total, 'active' => $active];
|
|
|
+ }
|
|
|
+
|
|
|
public function findById(int $id): ?Student
|
|
|
{
|
|
|
return Student::find($id);
|