Skip to content

Commit ef717fa

Browse files
committed
Added getRouteBindingQuery documentation to README
1 parent afa615b commit ef717fa

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,27 @@ Be advised that this package overrides the `getRouteKeyName` method, which means
109109

110110
When using Route Model Binding, some other interesting features become available.
111111

112+
### Custom Route Model Binding Query
113+
114+
Sometimes you'd want to add custom behavior to the query Laravel performs. This packages makes it possible to hook into the query by defining a `getRouteBindingQuery` method on the model, which could be useful in several cases such as including soft-deleted results :
115+
116+
```php
117+
namespace App;
118+
119+
use Whitecube\Sluggable\HasSlug;
120+
121+
class Post extends Model
122+
{
123+
use HasSlug;
124+
125+
// ...
126+
127+
protected function getRouteBindingQuery($query) {
128+
return $query->withTrashed();
129+
}
130+
}
131+
```
132+
112133
### Cross-language redirects
113134

114135
If the slug provided in the URL does not correspond to the current locale's slug translation, but corresponds to a slug in another language, this package can automatically redirect to the proper slug.

0 commit comments

Comments
 (0)