Skip to content

Commit f8504dd

Browse files
committed
Update README.md documentation and formatting
1 parent 63e2c91 commit f8504dd

File tree

1 file changed

+31
-8
lines changed

1 file changed

+31
-8
lines changed

README.md

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
[![License][badge_license]][link_license]
99

1010
## 📂 About
11+
1112
Useful eloquent model support traits.
1213

1314
## 📦 Installation
@@ -94,25 +95,47 @@ $model->slugNotIn(['any-string', 'any-string']); // will return $query->whereNot
9495

9596
This trait allows you to generate a slug from a title field. Same as [Sluggable](#sluggable) trait but it only works with the title field.
9697

98+
> **Note**
99+
> Field names are `slug` and `title` (hardcoded, not configurable).
100+
97101
```php
98102

99103
use LaravelReady\ModelSupport\Traits\SluggableTitle;
100104
...
105+
106+
$model->slug('any-string'); // will return $query->where('slug', $slug);
107+
$model->slugLike('any-string'); // will return $query->where('slug', 'like', $slug);
108+
$model->slugNot('any-string'); // will return $query->where('slug', '!=', $slug);
109+
$model->slugNotLike('any-string'); // will return $query->where('slug', 'not like', $slug);
110+
$model->slugIn(['any-string', 'any-string']); // will return $query->whereIn('slug', $slug);
111+
$model->slugNotIn(['any-string', 'any-string']); // will return $query->whereNotIn('slug', $slug);
112+
101113
```
102114

103115
### SluggableName
104116

105117
This trait allows you to generate a slug from a name field. Same as [Sluggable](#sluggable) trait but it only works with the name field.
106118

119+
> **Note**
120+
> Field names are `slug` and `name` (hardcoded, not configurable).
121+
107122
```php
108123

109124
use LaravelReady\ModelSupport\Traits\SluggableName;
110125
...
126+
127+
$model->slug('any-string'); // will return $query->where('slug', $slug);
128+
$model->slugLike('any-string'); // will return $query->where('slug', 'like', $slug);
129+
$model->slugNot('any-string'); // will return $query->where('slug', '!=', $slug);
130+
$model->slugNotLike('any-string'); // will return $query->where('slug', 'not like', $slug);
131+
$model->slugIn(['any-string', 'any-string']); // will return $query->whereIn('slug', $slug);
132+
$model->slugNotIn(['any-string', 'any-string']); // will return $query->whereNotIn('slug', $slug);
133+
111134
```
112135

113136
### ParentChild
114137

115-
This trait allows you to get all children of the model.
138+
This trait allows you to work with parent-child relationships in self-referencing models.
116139

117140
> **Note**
118141
> Field name is `parent_id` by default. You can change it in the config file.
@@ -125,17 +148,17 @@ This trait allows you to get all children of the model.
125148
use LaravelReady\ModelSupport\Traits\ParentChild;
126149
...
127150

128-
$model->parent(); // will return parent model
129-
$model->children(); // will return children models
130-
$model->allChildren(); // will return all children models
131-
$model->allChildrenIds(); // will return all children ids
132-
$model->recursiveParentAndChildren(); // will return all parent and children models
151+
$model->parent(); // will return parent model (BelongsTo relationship)
152+
$model->children(); // will return children models (HasMany relationship)
153+
$model->recursiveParent(); // will return parent with all recursive parents
154+
$model->recursiveChildren(); // will return children with all recursive children
155+
$model->recursiveParentAndChildren(); // will return parent and children recursively
133156

134157
```
135158

136159
### HasActive
137160

138-
This trait allows you to get active/inactive status models.
161+
This trait allows you to get active/inactive status models.
139162

140163
> **Note**
141164
> Field name is `is_active` by default. You can change it in the config file.
@@ -154,7 +177,7 @@ $model->inactive(); // will return $query->where('is_active', false);
154177

155178
```
156179

157-
## ⚓Credits
180+
## Credits
158181

159182
- This project was generated by the **[packager](https://github.com/laravel-ready/packager)**.
160183

0 commit comments

Comments
 (0)