avenirer / CodeIgniter-MY_Model

Base model (MY_Model) for the Codeigniter framework.
325 stars 203 forks source link

Getting soft deleted rows by get_relate functionality of many to many relationship #143

Open seicke opened 8 years ago

seicke commented 8 years ago

I've got the following three models:

users

$this->table        = 'users';
$this->primary_key  = 'id';
$this->soft_deletes = true;

groups_users

$this->table = 'groups_users';
$this->primary_key = 'uid';
$this->soft_deletes = true;

groups

$this->table        = 'groups';
$this->primary_key  = 'id';
$this->soft_deletes = true;

$this->has_many_pivot['users'] = array(
    'foreign_model'     => 'User_model',
    'pivot_table'       => 'groups_users',
    'local_key'         => 'id',
    'pivot_local_key'   => 'group_id',
    'pivot_foreign_key' => 'user_id',
    'foreign_key'       => 'id',
        'get_relate'    => true,
);

With

$this->group_model
    ->with_users('fields:lastname,firstname,domain,alias')
    ->where('id', $id)
    ->get();

I get also the user data with soft deleted relationships of the pivot table groups_users.

At the moment I'm not sure if it is a bug or if I made a mistake. I'm grateful for any help.

Thanks in advance!

johnnyhertogs2 commented 7 years ago

I'm having the same issue.