add projet
This commit is contained in:
Executable
+24
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
use App\Models\BaseModel;
|
||||
|
||||
class FamilyStudent extends BaseModel {
|
||||
protected $table = 'family_students';
|
||||
protected $primaryKey = 'id';
|
||||
protected $fillable = [
|
||||
'family_id',
|
||||
'student_id',
|
||||
'is_primary_home',
|
||||
'notes',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
public $timestamps = true;
|
||||
|
||||
public function getFamiliesForStudent(int $studentId): array {
|
||||
$db = \Config\Database::connect();
|
||||
$sql = "SELECT f.* , fs.is_primary_home\n FROM family_students fs\n JOIN families f ON f.id = fs.family_id\n WHERE fs.student_id = ? AND f.is_active = 1\n ORDER BY fs.is_primary_home DESC, f.household_name";
|
||||
return $db->query($sql, [$studentId])->getResultArray();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user