使用laravel 4我正在嘗試向我的數據庫添加'active'列以檢查用戶是否處於活動狀態並且未掛起,這裏是我的遷移用戶表。laravel檢查用戶是否活動?
public function up()
{
//
Schema::create(
'users',
function (Blueprint $table) {
$table->increments('id');
$table->string('email', 300);
$table->string('password', 60);
$table->boolean('active'); // check this one
$table->string('first_name', 100);
$table->string('last_name', 100);
$table->string('address', 250)->nullable();
$table->string('city', 100)->nullable();
$table->string('state', 2)->nullable();
$table->string('zip', 5)->nullable();
$table->string('phone', 10)->nullable();
$table->timestamps();
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
Schema::drop('users');
}
如果我使用$ table-> boolean('active'),你能幫助我嗎? //檢查這一個
* 這是正確的方法嗎?所以我可以像這樣使用Auth類來檢查用戶是否活動? *
$is_active = Auth::user()->active;
if (!$is_active == 1)
{
echo "Account not activated";
}
除了將其命名爲「活動」而不是「激活」之外,沒關係。如果您想要添加一個字段,告訴您用戶未處於活動狀態(禁用或其他),則會更容易閱讀。 –
但拉拉維爾如何讀取它'活躍'或'激活'或拉拉維爾知道嗎? – user3150060
或者你的意思是,如果我把它'激活',然後檢查:Auth :: user() - >激活; ? – user3150060