laravel 4 내 데이터베이스에 '활성'열을 추가하여 사용자가 활성화되어 있고 일시 중지되지 않았는지 확인하려고합니다. 여기에 내 마이그레이션 사용자 테이블이 있습니다.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 클래스를 사용하여 사용자가 활성화되어 있는지 확인합니다. Laravel\Docs\Authentication
그냥 내 2 비트 : 방법 구축
if (Auth::attempt(array('email' => $email, 'password' => $password, 'active' => 1)))
{
// The user is active, not suspended, and exists.
}
읽기 *
$is_active = Auth::user()->active;
if (!$is_active == 1)
{
echo "Account not activated";
}
'활성화'대신 '활성'으로 지정하는 것 외에는 괜찮습니다. 사용자가 활성화되어 있지 않다는 것을 알려주는 필드를 추가하려는 경우 (읽기 또는 쓰기가 더 쉽습니다). –
그러나 laravel이 '활성'또는 '활성화 됨'을 읽는 방법 또는 laravel이 알 수있는 중요하지 않은 방법은 무엇입니까? – user3150060
또는 다음을 확인하기 위해 '활성화'한 경우 : Auth :: user() -> activated; ? – user3150060