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

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.
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