tattersoftware / codeigniter4-relations

Entity relationships for CodeIgniter 4
MIT License
87 stars 20 forks source link

Add function withoutAny. #10

Closed sfadschm closed 3 years ago

sfadschm commented 3 years ago

Adds a function withoutAny to the ModelTrait.

This might be particularily useful when using an Entity with the Model->save() method. The function disables loading of all relation tables in this case. Otherwise, relations defined in the Model ($with = 'xxx';) will be loaded to the Entity that is being updated and will make hasChanged() return true even if no changes are submitted.

Not really confident with the implementation. I guess settingtmpWith = null; would do the same. The functionality could also be realized by allowing $tables to be null in without($tabes) and then handling it there.

MGatner commented 3 years ago

This is duplicate functionality to calling $model->with(false). I would like to move away from this current implementation of using booleans for "negative functionality" but I don't think withoutAny() will be the solution.

For now if you need this just us with(false).

sfadschm commented 3 years ago

Totally right, I should have checked the PHPDocs, thanks :-D

MGatner commented 3 years ago

No worries! Documentation is definitely behind on this library. So much to do in CodeIgniter and modules, docs & testing are still lagging 😭

sfadschm commented 3 years ago

Well as far as I am concerned, this module works great and saved me a lot of implementation time as I tend to rewrite relation loading with every (non-work related) project. Keep it up :)