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

Filter Bundle Laravel Package

alhames/filter-bundle

View on GitHub
Deep Wiki
Context7
    public function getDbField(array $config = []): string;
    /**
     * [@dataProvider](https://github.com/dataProvider) provideGetDbField
     */
    public function testGetDbField(mixed $expected, array $config = []): void
    {
        $filter = $this->getFilter();
        $this->assertSame($expected, $filter->getDbField($config));
    }

    abstract protected function provideGetDbField(): array;

Boolean

    public function getDbField(array $config = []): string
    {
        $default = $this->getDefaultValue($config);
        $config = array_merge($this->config, $config);
        $field = 'TINYINT(1) UNSIGNED';
        if ($config['required']) {
            $field .= ' NOT NULL';
        } elseif (null === $default) {
            $field .= ' NULL DEFAULT NULL';
        } else {
            $field .= sprintf(" NOT NULL DEFAULT '%d'", $default);
        }

        return $field;
    }
    protected function provideGetDbField(): array
    {
        return [
            ['expected' => 'TINYINT(1) UNSIGNED NULL DEFAULT NULL'],
            [
                'expected' => 'TINYINT(1) UNSIGNED NOT NULL',
                'config' => ['required' => true],
            ],
            [
                'expected' => 'TINYINT(1) UNSIGNED NOT NULL DEFAULT 0',
                'config' => ['default' => false],
            ],
        ];
    }

Float

    public function getDbField(array $config = []): string
    {
        $default = $this->getDefaultValue($config);
        $config = array_merge($this->config, $config);
        $signed = $config['min'] < 0;

        if ('integer' === $config['format']) {
            $field = '';
        } else {
            // FLOAT[(M,D)] [SIGNED | UNSIGNED | ZEROFILL]
            // DOUBLE[(M,D)] [SIGNED | UNSIGNED | ZEROFILL]
            $max = $signed ? self::DB_MAX_SIGNED_FLOAT : self::DB_MAX_UNSIGNED_FLOAT;
            $field = $config['max'] > $max ? 'DOUBLE' : 'FLOAT';
            $field .= $signed ? ' SIGNED' : ' UNSIGNED';
        }

        if ($config['required']) {
            $field .= ' NOT NULL';
        } elseif (null === $default) {
            $field .= ' NULL DEFAULT NULL';
        } else {
            $field .= sprintf(" NOT NULL DEFAULT '%s'", $default);
        }

        return $field;
    }

IP

    public function getDbField(array $config): string
    {
        $config = array_merge($this->config, $config);
        $field = 'INT(10) UNSIGNED';
        if ($config['required']) {
            $field .= ' NOT NULL';
        } elseif (null === $config['default']) {
            $field .=  ' NULL DEFAULT NULL';
        } else {
            $field .=  sprintf(" NOT NULL DEFAULT '%d'", $config['default']);
        }

        return $field;
    }
    protected function provideGetDbField(): array
    {
        return [
            ['expected' => 'INT(10) UNSIGNED NULL DEFAULT NULL'],
        ];
    }
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.
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel
draftsmaninc/draftsman
square-bit/laravel-volition
himito/laravel-mailman
htinlynn/genius-helper
maco-studios/hephaestus
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log