0
在Laravel創建新用戶時5.1某些字段不節能 - Laravel 5.1註冊
user.php的
<?php
namespace App;
use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Foundation\Auth\Access\Authorizable;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
class User extends Model implements AuthenticatableContract,
AuthorizableContract,
CanResetPasswordContract
{
use Authenticatable, Authorizable, CanResetPassword;
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'laravel_users';
public $timestamps = false;
protected $primaryKey = 'id';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'username',
'password',
'role_id',
'email',
'avatar',
'isActive',
];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = ['password', 'remember_token'];
public function isAdministrator()
{
return false;
}
public function blogs()
{
return $this->hasMany('App\Models\Blog');
}
}
authcontroller.php
我有一個問題<?php
namespace App\Http\Controllers\Auth;
use Socialite;
use Illuminate\Routing\Controller;
#use App\Http\Controllers\Controller;
use Redirect;
use App\User;
use Validator;
use Auth;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
class AuthController extends Controller
{
use AuthenticatesAndRegistersUsers, ThrottlesLogins;
protected $redirectTo = '/admin';
public function __construct()
{
$this->middleware('guest', ['except' => 'getLogout']);
}
//temporarily redirected to duterte-run.mendanielle.com
public function getRegister()
{
return view('auth.register');
}
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'username' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|confirmed|min:6',
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
*/
protected function create(array $data)
{
return User::create([
'username' => $data['username'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
}
/**
* Redirect the user to the GitHub authentication page.
*
* @return Response
*/
public function redirectToProvider()
{
return Socialite::with('facebook')->redirect();
}
/**
* Obtain the user information from GitHub.
*
* @return Response
*/
public function handleProviderCallback()
{
//retrieve user's information from facebook
$user = Socialite::with('facebook')->user();
}
}
我不知道爲什麼電子郵件字段不存儲和PHP工匠修補程序返回沒有錯誤
此外,mysql字段是相關的CT和手動添加值內mysql命令works.Any想法呢?
這是一個不工作的電子郵件/密碼用戶,或Github社交用戶? – andrewtweber
@andrewtweber我創建了一個允許Github社交和傳統登錄形式的表單。我不知道它是否是正確的方式,因爲我是Laravel的新手,正如您所看到的,社交名稱的重定向和回調函數是'嵌入'在AuthController中,其中包含用戶的電子郵件/密碼。 –