我需要一些帮助。例子:
$table->text('description');
但是,如何编码/编写,如果我想我的数据类型是'LONGTEXT' ?
我找不到这方面的文档@ http://laravel.com/docs/schema
谢谢!
Laravel 4.2/5.1+
直接使用最近添加的longText
方法。
Schema::create('posts', function ($table) {
$table->increments('id');
$table->integer('user_id');
// ...
$table->longText('description');
// ...
}
Pre-Laravel 4.2/5.1
对于常规的Laravel Schema类没有办法做到这一点,因为它不实现这种类型。如果确实需要,可以使用Schema类创建表,然后使用SQL查询修改表以添加该字段。例如,可以这样写:
Schema::create('posts', function ($table) {
$table->increments('id');
$table->integer('user_id');
// ...
$table->text('description');
// ...
}
DB::statement('ALTER TABLE `posts` COLUMN `description` `description` LONGTEXT;');
现在可以使用了。从docs
$table->longText('description');
Schema::table('table_namae', function (Blueprint $table) {
$table->longText('column_name');
});
您需要简单地将数据类型长文本写入字符串
Schema::table('table name ', function (Blueprint $table) {
$table->longText('attachments');
});
我有这项工作给你。
的更多细节,请通过链接https://laravel.com/docs/4.2/schema