Comments (4)
I think the issue is that replicate()
doesn't change the exists
field of the new model. So, as far as eloquent-sluggable is concerned, the model already exists and the slug field is populated. The check on lines 48-54 of Sluggable.php will skip all processing:
// skip slug generation if the model exists or the slug field is already populated,
// and on_update is false ... unless we are forcing things!
if ( !$force )
{
if ( ( $model->exists || !empty($model->{$save_to}) ) && !$on_update )
{
return true;
}
}
Unless the replicate()
method changes somehow (unsetting $this->exists
or firing a specific replicate event), I don't see how I can fix this without forcing a reslugging on each save (which will likely break other stuff). Your safest bet is to force the slugging when you replicate:
$new_model = $old_model->replicate();
Sluggable::make($new_model,true);
from eloquent-sluggable.
On further inspection, I need to add another check when forcing the slugging to make this work. Fix is coming soon ... (although you will still need to manually run Sluggable::make()
to force new slug generation).
from eloquent-sluggable.
Fixed in 1.0.8.
from eloquent-sluggable.
Awesome, thanks
from eloquent-sluggable.
Related Issues (20)
- Conditionally force new slug HOT 4
- slug another language HOT 1
- Checking the pull request HOT 1
- Sluggable HOT 1
- throw new \UnexpectedValueException HOT 2
- Я
- Laravel 10 support HOT 8
- Laravel 10 Install issue... HOT 1
- Should findBySlugOrFail return Model instead? HOT 1
- Issue when testing a model factory using make() HOT 3
- Turkish character slug problem
- Slugging behavior when creating a new model varies depending on onUpdate setting HOT 4
- Is it possible to use the slug as source? HOT 4
- SluggableScopeHelpers Trait: Support for orWhere and whereIn HOT 1
- Slugging with Laravel Nova HOT 4
- Remove HTML Tags Before Creating Slug HOT 3
- Bug when using $with properties that include belongTo relationships HOT 7
- Case-sensitivity and slug uniqueness HOT 2
- Tag 11.0 version. Laravel 11 just landed 🌕 🚀 HOT 2
- Generate slug from the same field if explicitly modified HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eloquent-sluggable.