Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Doctrine Behaviors Laravel Package

eightmarq/doctrine-behaviors

View on GitHub
Deep Wiki
Context7

Sluggable

Sluggable generates slugs (uniqueness is not guaranteed) for an entity.

Will automatically generate on update/persist (you can disable the on update generation by overriding shouldRegenerateSlugOnUpdate() to return false.

You can also override the slug delimiter from the default - by overriding getSlugDelimiter() method.

Slug generation algo can be changed by overriding generateSlugValue().

Use cases include SEO (i.e. URLs like http://example.com/post/3/introduction-to-php)

<?php

declare(strict_types=1);

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use Knp\DoctrineBehaviors\Contract\Entity\SluggableInterface;
use Knp\DoctrineBehaviors\Model\Sluggable\SluggableTrait;

/**
 * [@ORM](https://github.com/ORM)\Entity
 */
class BlogPost implements SluggableInterface
{
    use SluggableTrait;

    /**
     * [@ORM](https://github.com/ORM)\Column(type="string")
     * [@var](https://github.com/var) string
     */
    private $title;

    /**
     * [@return](https://github.com/return) string[]
     */
    public function getSluggableFields(): array
    {
        return ['title'];
    }

    public function generateSlugValue($values): string
    {
        return implode('-', $values);
    }
}
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings
coleus/apps
seampact/laravel
emmyconceptng/laravel-ng-postcode
jjsquady/round-robin
skyraptor/chatter
edlugz/sasapay
abbasudo/artisan-route