嘿,我已经在那里搜索了很多答案,但无法解决这个问题。
这是我的迁移代码
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateActiveTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('activations', function($table)
{
$table->bigInteger('id')->primary();
$table->tinyInteger('token');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('activations');
}
}
对于型号(模型/Activation.php)
<?php
class Activation extends Eloquent {
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'activations';
protected $guarded = array();
}
我这样调用激活表。
Activation::create(['id' => 2, 'token' => 1231]);
说真的,我不知道这里出了什么问题。我是 laravel 4 的新手。希望有人教我发生了什么以及如何解决它。
您需要使用$fillable
您的财产Activation
当你使用类批量分配.
class Activation extends Eloquent {
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'activations';
protected $fillable = ['id', 'token'];
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)