Hello,
Today, I'll try to tell about a little tiny trick about PHP traits using Laravel as example.
I'll rename a private method in PHP traits and use it like a public method.
There is an awesome package for Laravel called Eloquent-Sluggable created by Colin Viebrock, which I've been using since Laravel 4.
I couldn't find a similar article for the same purpose with this package, so I decided to write a simple blog post.
Today, in a project, I needed to create the slug before saving. First, I thought of running the method directly in a model, so I tried running
Model::makeSlugUnique('my-slug-that-may-not-be-unique');
But as expected, it failed, because its property was protected, and I should not fetch