viraj-khatavkar / easy-slug Goto Github PK
View Code? Open in Web Editor NEWA laravel package for creating slugs easily
A laravel package for creating slugs easily
Clients began to complain about the wrong records being retrieved when they clicked on links and I assumed that I had forgotten to enable EasySlug when creating those entries. I checked my code and found that I had indeed used EasySlug::generateUniqueSlug()
.
If I have an entry with a slug of football-season
on my seasons
table, EasySlug will generate the next slug as football-season
. However, if I change the slug on the table to football-season-1
, EasySlug generates the next as football-season-2
.
As a test I tried using the wrong table name to see the SQL query behind the scenes and noticed this:
$title = "Football Season";
$slug = EasySlug::generateUniqueSlug($title, "season", "slug");
select count(*) as aggregate from `season` where `slug` LIKE football-season-%
So it appears to be looking only for the number of items with -%
in their slug, not simply a slug without the number of entries.
Am I missing something? This worked until recently, perhaps a breaking change somewhere?
Adding "easy-slug/easy-slug": "2.0." to composer.json with laravel 5.0.16, concludes that it should uninstall laravel, because "easy-slug/easy-slug v2.0.0 requires illuminate/database 4. -> satisfiable by illuminate/database[v4.0.0, v4.0.1, v4.0.10, v4.0.2, v4.0.3, v4.0.4, v4.0.5, v4.0.6, v4.0.7, v4.0.8, v4.0.9, v4.1.0, v4.1.1, v4.1.10, v4.1.11, v4.1.12, v4.1.13, v4.1.14, v4.1.15, v4.1.16, v4.1.17, v4.1.18, v4.1.19, v4.1.2, v4.1.20, v4.1.21, v4.1.22, v4.1.23, v4.1.24, v4.1.25, v4.1.26, v4.1.27, v4.1.28, v4.1.29, v4.1.3, v4.1.30, v4.1.4, v4.1.5, v4.1.6, v4.1.7, v4.1.8, v4.1.9, v4.2.1, v4.2.12, v4.2.16, v4.2.17, v4.2.2, v4.2.3, v4.2.4, v4.2.5, v4.2.6, v4.2.7, v4.2.8, v4.2.9]", and none of those illuminate/database are concluded to work with L5.
I found the issue when using Easy Slug for user registrations. The generateUniqueSlug method fails in the following scenario.
if slug for user1 is abc-xyz
if slug is generated for new user then new slug will be generated as abc-xyz-2
Now if the record with fist slug abc-xyz is modified OR deleted then the generateUniqueSlug method fails to generate a unique slug i.e. abc-xyz-2 is generated as new slug
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.