recreate project
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class FamilyStudentModel extends Model {
|
||||
protected $table = 'family_students';
|
||||
protected $primaryKey = 'id';
|
||||
protected $allowedFields = ['family_id','student_id','is_primary_home','notes'];
|
||||
|
||||
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