refactoring

This commit is contained in:
root
2026-01-12 18:15:12 +03:00
parent 077b79b8f7
commit c55264cf42
5 changed files with 274 additions and 422 deletions
+13 -4
View File
@@ -20,10 +20,19 @@ class OrganizationModel extends Model
protected $deletedField = 'deleted_at';
// Получить организации конкретного пользователя
public function getUserOrganizations(int $userId)
public function getUserOrganizations(int $userId): array
{
// TODO: Здесь мы будем делать JOIN с таблицей organization_users
// Пока упрощенная версия для владельца
return $this->where('owner_id', $userId)->findAll();
$db = $this->db();
$builder = $db->newQuery();
return $builder->select('o.*, ou.role, ou.status as membership_status, ou.joined_at')
->from('organizations o')
->join('organization_users ou', 'ou.organization_id = o.id', 'inner')
->where('ou.user_id', $userId)
->where('ou.status', 'active')
->where('o.deleted_at', null)
->orderBy('ou.joined_at', 'ASC')
->get()
->getResultArray();
}
}