noud/laravel-schema-real-binary

Laravel大小写敏感的Schema列类型

v1.0.0 2020-09-10 22:04 UTC

This package is auto-updated.

Last update: 2024-09-11 07:53:52 UTC


README

INSERT INTO `country` (`id`, `currency`) VALUES
('demo', 'eur'),
('be', 'EUR'),
('nl', 'EUR');

INSERT INTO `currency` (`code`, `symbol`, `format`) VALUES
('eur', '', '{VALUE} {SYMBOL}'),
('EUR', '', '{SYMBOL} {VALUE}'),
('USD', '$', '{SYMBOL} {VALUE}');

创建列

此Laravel包通过在迁移中添加实际二进制列,为大小写敏感的字符串字段提供长度,并可作为主键和外键。

迁移

    Schema::create('currency', function (Blueprint $table) {
        $table->realBinary('code', 3)->unique();
        // works as well
        // $table->char('code', 3)->charset('binary')->unique();
        // more fields
    });

    Schema::create('country', function (Blueprint $table) {
        $table->string('id')->unique();
        $table->realBinary('currency', 3);
        // works as well
        // $table->char('currency', 3)->charset('binary');

        $table->foreign('currency')->references('code')->on('currency');
    });

新列类型

可用列类型

一起使用

灵感来源

此Laravel包受到以下启发: