first commit
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class OrganizationModel extends Model
|
||||
{
|
||||
protected $table = 'organizations';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = true; // Включаем мягкое удаление (deleted_at)
|
||||
protected $allowedFields = ['owner_id', 'name', 'type', 'logo', 'requisites', 'trial_ends_at', 'settings'];
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
// Получить организации конкретного пользователя
|
||||
public function getUserOrganizations(int $userId)
|
||||
{
|
||||
// TODO: Здесь мы будем делать JOIN с таблицей organization_users
|
||||
// Пока упрощенная версия для владельца
|
||||
return $this->where('owner_id', $userId)->findAll();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user