You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Update README.md
- Remove routes
- Add Livewire full-page components as handler
- Fix bug when triggering manually generateUrl() multiple times
- Fix bug when related model is null
- Fix bug in tests
Copy file name to clipboardExpand all lines: README.md
+83-21Lines changed: 83 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,15 @@
7
7
8
8
A package for using and generating unique urls for each Eloquent model in Laravel. This package is inspired by [spatie/laravel-sluggable](https://github.com/spatie/laravel-sluggable) but making the urls unique.
9
9
10
+
-[Installation](#installation)
11
+
-[Usage](#usage)
12
+
-[Configuration](#configuration)
13
+
-[Routes]()
14
+
-[Prepare your model](#prepare-your-model)
15
+
-[Disable auto creating urls](#batch-import)
16
+
-[Livewire](#livewire)
17
+
-[Contributing](#contributing)
18
+
10
19
### Goals:
11
20
- When create or update a model to generate a unique url based on urlStrategy() function inside each model
12
21
- If the url exists to create a new url with suffix _1, _2, etc.
If for example you have category tree and you need to import all the data before creating the urls, you can disable the automatic generation of the url on model creation
70
97
To disable automatically generating the urls on create or update overwrite the method `isAutoGenerateUrls` in the model:
71
98
```php
72
99
public function isAutoGenerateUrls(): bool
@@ -79,6 +106,41 @@ and call `generateUrl()` later like this:
To use [Livewire full-page component](https://laravel-livewire.com/docs/2.x/rendering-components#page-components) to handle the request, first set in `urlHandler()` function in your model:
112
+
```php
113
+
public function urlHandler(): array
114
+
{
115
+
return [
116
+
// The Livewire controller
117
+
'controller' => CategoryController::class,
118
+
// The method should be empty
119
+
'method' => '',
120
+
// additional arguments sent to the mount() function
121
+
'arguments' => [],
122
+
];
123
+
}
124
+
```
125
+
Example livewire component:
126
+
```php
127
+
class LivewireComponentExample extends Component
128
+
{
129
+
private Url $urlModel;
130
+
private array $url_arguments;
131
+
132
+
public function mount(Url $urlObj, $arguments = [])
0 commit comments