Weave Code
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

knplabs/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.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui