mscherer 2 years ago
parent
commit
75d6752288
2 changed files with 9 additions and 2 deletions
  1. 2 2
      docs/Behavior/Bitmasked.md
  2. 7 0
      docs/Behavior/Slugged.md

+ 2 - 2
docs/Behavior/Bitmasked.md

@@ -95,7 +95,7 @@ Alternatively, you can map the error over before the entity gets passed to the v
 You can use the built-in custom finder `findBitmasked`:
 ```php
 $statuses = [Comment::STATUS_ACTIVE, Comment::STATUS_FEATURED];
-$comments = $this->Comments->find('bits', ['bits' => $statuses])->toArray();
+$comments = $this->Comments->find('bits', bits: $statuses)->toArray();
 ```
 
 #### Using Search plugin
@@ -115,7 +115,7 @@ This way the array of checkboxes selected will be turned into the integer bitmas
 
 When using select dropdows or checkboxes, you usually want to use type `contain` instead of `exact` matching:
 ```php
-$this->Comments->find('bits', ['bits' => $statuses, 'type' => 'contain'])->toArray();
+$this->Comments->find('bits', bits: $statuses, options: ['type' => 'contain'])->toArray();
 ```
 It can also be useful to add a state for "no bits set" (all without any bits):
 ```php

+ 7 - 0
docs/Behavior/Slugged.md

@@ -166,3 +166,10 @@ $this->addBehavior('Tools.Slugged', ['mode' => [MySlugger::class, 'slug']]);
 
 Tip: Use `'mode' => [Text::class, 'slug']` if you want to avoid using the deprecated `Inflector::slug()` method.
 Don't forget the use statement at the top of the file, though (`use Tools\Utility\Text;`).
+
+### Using custom finder
+If you quickly want to find a record by its slug, use:
+```php
+->find()->find('slugged', slug: $slug)->firstOrFail();
+```
+etc