An open API service indexing awesome lists of open source software.

https://github.com/noud/laravel-schema-real-binary

Laravel realBinary, case sensitive string, Schema column type
https://github.com/noud/laravel-schema-real-binary

laravel laravel-package mysql schema sql

Last synced: about 1 month ago
JSON representation

Laravel realBinary, case sensitive string, Schema column type

Awesome Lists containing this project

README

          

# [Laravel](http://laravel.com) [realBinary](http://github.com/noud/laravel-schema-real-binary), [case sensitive](http://en.wikipedia.org/wiki/Case_sensitivity) string, [Schema](http://laravel.com/docs/migrations#tables) [column](http://laravel.com/docs/8.x/migrations#columns) type
```sql
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}');
```
## [Creating Columns](http://laravel.com/docs/migrations#creating-columns)
This Laravel package gives case sensative string fields with length and also as primary and foreign key
by adding a real binary column to migrations.
### migrations
```php
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');
});
```
### New Column Type

Command
Description

$table->realBinary('fullname');
BINARY equivalent column with length 255

$table->realBinary('code', 3);
BINARY equivalent with a length

### Available Column Type

Command
Description

$table->char('code', 3);
$table->char('name', 100);
CHAR equivalent column with a length.

used together with

Modifier
Description

->charset('binary');
Specify a character set for the column (MySQL)
make the column equivalent with BINARY.

## inspirations
This Laravel package is inspired by

- [Laravel Schema Builder : Creating a binary(16) column](http://stackoverflow.com/questions/49389233/laravel-schema-builder-creating-a-binary16-column)
- [Laravel Doctrine Extensions](http://github.com/laravel-doctrine/extensions)
- [Doctrine Behavioral Extensions](http://github.com/Atlantic18/DoctrineExtensions)
- [DoctrineExtensions](http://github.com/beberlei/DoctrineExtensions)
- [Extended Schema builder for Laravel 5](http://github.com/rafis/schema-extended)