use*_*596 9 php laravel eloquent laravel-4
嘿,我已经搜索了很多答案,但无法解决这个问题.
这是我迁移的代码
<?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');
}
}
Run Code Online (Sandbox Code Playgroud)
对于型号(型号/ Activation.php)
<?php
class Activation extends Eloquent {
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'activations';
protected $guarded = array();
}
Run Code Online (Sandbox Code Playgroud)
我正在调用这样的激活表.
Activation::create(['id' => 2, 'token' => 1231]);
Run Code Online (Sandbox Code Playgroud)
说真的,我不知道这里有什么问题.我是laravel 4的新手.希望有人教我发生什么,以及如何解决它.
Mar*_*lln 22
使用批量分配时,需要$fillable在Activation类中使用该属性.
class Activation extends Eloquent {
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'activations';
protected $fillable = ['id', 'token'];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9359 次 |
| 最近记录: |