hermawanramadhan / CodeIgniter4-DataTables

MIT License
92 stars 38 forks source link

Implement ci4 softDelete compatibility #46

Open nicojmb opened 3 months ago

nicojmb commented 3 months ago

if i've a model with softDelete enabled, the query not skipts this items automatically.

https://codeigniter.com/user_guide/models/model.html#usesoftdeletes

kangzul commented 1 month ago

i dont know this is correct answer or not. but i change of code on construction function inside Datatables.php like this


public function __construct($builder)
{
    if (is_subclass_of($builder, '\CodeIgniter\BaseModel') && method_exists($builder, 'builder')) {
        if ($builder->tempUseSoftDeletes) {
            $builder->where($builder->table . '.' . $builder->deletedField, null);
        }
        $builder = $builder->builder();
    }
    $this->query      = new DataTableQuery($builder);
    $this->columnDefs = new DataTableColumnDefs($builder);
}