Skip to content

Blueprint Macro: String

Nasrul Hazim Bin Mohamad edited this page Jun 18, 2018 · 2 revisions

The Blueprint Macro String simplify setup of text based field name, such first_name, last_name, etc.

There's 3 type of string macros.

Short String

name() and label() have same implementation. Use either one of it.

code() same setup as name() or label() except with added as unique and index.

reference() same with code() but default length is 64 instead of 20 characters.

// Macro: name()
$table->name(); // column name: name, length: 255
$table->name('first_name'); // column name: first_name, length: 255
$table->name('first_name', 64); // column name: first_name, length: 64

// Macro: label()
$table->label(); // column name: label, length: 255
$table->label('custom_label'); // column name: custom_label, length: 255
$table->label('custom_label', 64); // column name: custom_label, length: 64

// Macro: code()
$table->code(); // column name: code, length: 20
$table->code('payment_code'); // column name: payment_code, length: 20
$table->code('payment_code', 64); // column name: payment_code, length: 64

// Macro: reference()
$table->reference(); // column name: reference, length: 64
$table->reference('document_reference'); // column name: document_reference, length: 64
$table->reference('document_reference', 128); // column name: document_reference, length: 128

Long String

Both description() and remarks() have same setup of text data type and nullable. The only difference is the column name.

To change the column name, just pass in the first argument the column name to use.

// Macro: description()
$table->description();
$table->description('product_description');

// Macro: remarks()
$table->remarks();
$table->remarks('product_remarks');
Clone this wiki locally