@@ -124,7 +124,7 @@ to set those conditions inside the init() method of your model::
124124
125125 class Model_Girl extends Model_User
126126 {
127- function init(): void
127+ protected function init(): void
128128 {
129129 parent::init();
130130
@@ -254,7 +254,7 @@ These classes can be used directly and independently from Model class.
254254
255255 This method provides access to the model scope enabling conditions to be added::
256256
257- $contact->scope()->addCondition($condition); // adding condition to a model
257+ $contact->scope()->addCondition($condition); // adding condition to a model
258258
259259.. php :class :: Scope
260260
@@ -264,53 +264,53 @@ e.g ((Name like 'ABC%' and Country = 'US') or (Name like 'CDE%' and (Country = '
264264
265265Scope can be created using new Scope() statement from an array or joining Condition objects or condition arguments arrays::
266266
267- // $condition1 will be used as nested condition
268- $condition1 = new Condition('name', 'like', 'ABC%');
267+ // $condition1 will be used as nested condition
268+ $condition1 = new Condition('name', 'like', 'ABC%');
269269
270- // $condition2 will converted to Condtion object and used as nested condition
271- $condition2 = ['country', 'US'];
270+ // $condition2 will converted to Condtion object and used as nested condition
271+ $condition2 = ['country', 'US'];
272272
273- // $scope1 is created using AND as junction and $condition1 and $condition2 as nested conditions
274- $scope1 = Scope::createAnd($condition1, $condition2);
273+ // $scope1 is created using AND as junction and $condition1 and $condition2 as nested conditions
274+ $scope1 = Scope::createAnd($condition1, $condition2);
275275
276- $condition3 = new Condition('country', 'DE');
277- $condition4 = ['surname', 'XYZ'];
276+ $condition3 = new Condition('country', 'DE');
277+ $condition4 = ['surname', 'XYZ'];
278278
279- // $scope2 is created using OR as junction and $condition3 and $condition4 as nested conditions
280- $scope2 = Scope::createOr($condition3, $condition4);
279+ // $scope2 is created using OR as junction and $condition3 and $condition4 as nested conditions
280+ $scope2 = Scope::createOr($condition3, $condition4);
281281
282- $condition5 = new Condition('name', 'like', 'CDE%');
282+ $condition5 = new Condition('name', 'like', 'CDE%');
283283
284- // $scope3 is created using AND as junction and $condition5 and $scope2 as nested conditions
285- $scope3 = Scope::createAnd($condition5, $scope2);
284+ // $scope3 is created using AND as junction and $condition5 and $scope2 as nested conditions
285+ $scope3 = Scope::createAnd($condition5, $scope2);
286286
287- // $scope is created using OR as junction and $scope1 and $scope3 as nested conditions
288- $scope = Scope::createOr($scope1, $scope3);
287+ // $scope is created using OR as junction and $scope1 and $scope3 as nested conditions
288+ $scope = Scope::createOr($scope1, $scope3);
289289
290290
291291Scope is an independent object not related to any model. Applying scope to model is using the Model::scope()->add($condition) method::
292292
293- $contact->scope()->add($condition); // adding condition to a model
294- $contact->scope()->add($conditionXYZ); // adding more conditions
293+ $contact->scope()->add($condition); // adding condition to a model
294+ $contact->scope()->add($conditionXYZ); // adding more conditions
295295
296296.. php :method :: __construct($nestedConditions = [], $junction = Scope::AND);
297297
298298 Creates a Scope object from an array::
299299
300- // below will create 2 conditions and nest them in a compound conditions with AND junction
301- $scope1 = new Scope([
302- ['name', 'like', 'ABC%'],
303- ['country', 'US'],
304- ]);
300+ // below will create 2 conditions and nest them in a compound conditions with AND junction
301+ $scope1 = new Scope([
302+ ['name', 'like', 'ABC%'],
303+ ['country', 'US'],
304+ ]);
305305
306306.. php :method :: negate();
307307
308308 Negate method has behind the full map of conditions so any condition object can be negated, e.g negating '>=' results in '<', etc.
309309For compound conditionss this method is using De Morgan's laws, e.g::
310310
311- // using $scope1 defined above
312- // results in "(Name not like 'ABC%') or (Country does not equal 'US')"
313- $scope1->negate();
311+ // using $scope1 defined above
312+ // results in "(Name not like 'ABC%') or (Country does not equal 'US')"
313+ $scope1->negate();
314314
315315.. php :method :: createAnd(...$conditions);
316316
@@ -357,15 +357,15 @@ If $value is omitted as argument then $operator is considered as $value and '='
357357
358358 Negates the condition, e.g::
359359
360- // results in "name != 'John'"
361- $condition = (new Condition('name', 'John'))->negate();
360+ // results in "name != 'John'"
361+ $condition = (new Condition('name', 'John'))->negate();
362362
363363.. php :method :: toWords(Model $model = null);
364364
365365 Converts the condition object to human readable words. Condition must be assigned to a model or model argument provided::
366366
367- // results in 'Contact where Name is John'
368- (new Condition('name', 'John'))->toWords($contactModel);
367+ // results in 'Contact where Name is John'
368+ (new Condition('name', 'John'))->toWords($contactModel);
369369
370370Conditions on Referenced Models
371371-------------------------------
@@ -375,15 +375,15 @@ Agile Data allows for adding conditions on related models for retrieval of type
375375Setting conditions on references can be done utilizing the Model::refLink method but there is a shorthand format
376376directly integrated with addCondition method using "/" to chain the reference names::
377377
378- $contact->addCondition('company/country', 'US');
378+ $contact->addCondition('company/country', 'US');
379379
380380This will limit the $contact model to those whose company is in US.
381381'company' is the name of the reference in $contact model and 'country' is a field in the referenced model.
382382
383383If a condition must be set directly on the existence or number of referenced records the special symbol "#" can be
384384utilized to indicate the condition is on the number of records::
385385
386- $contact->addCondition('company/tickets/#', '>', 3);
386+ $contact->addCondition('company/tickets/#', '>', 3);
387387
388388This will limit the $contact model to those whose company have more than 3 tickets.
389389'company' and 'tickets' are the name of the chained references ('company' is a reference in the $contact model and
0 commit comments