laravel5.1のAuth機能をusersテーブルではないテーブルで使いたいです。hひとまずユーザー登録を試みたのですが、自分が調べたものだけでは不十分なのかうまくいきません。テーブル名をnewusersにしemailをnewemailとして以下のように変更してみたのですが・・..
User.php protected $table = 'newusers'; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = ['name', 'newemail', 'password']; /** * The attributes excluded from the model's JSON form. * * @var array */ protected $hidden = ['password', 'remember_token']; }
AuthController.php protected function validator(array $data) { return Validator::make($data, [ 'name' => 'required|max:255', 'newemail' => 'required|email|max:255|unique:newusers', 'password' => 'required|confirmed|min:6', ]); } protected function create(array $data) { return User::create([ 'name' => $data['name'], 'newemail' => $data['newemail'], 'password' => bcrypt($data['password']), ]); }
auth.php 'model' => App\User::class, 'table' => 'newusers',
他にも何か変更すべき点があるのでしょうか?パスワードリセットなどは
とりあえず放置してるので変更はしていません。
どこかのタイミングで`Auth::attempt()`か`auth()->attempt()`をやっていると思います。その認証周りのコードを貼っていただけないでしょうか? ※下のコメントは削除リクエストを出しました。
Auth::attemptは使ってないです。attemptの個人的な解釈としては参照するカラムを自由に選択するといった感じなのですが、私が今回やりたいのはAuth機能を使いつつテーブルもカラムも全く違ったものを使いたいのです。それともattemptの解釈自体何か間違ってるでしょうか?無知ですみません・・・
回答1件
あなたの回答
tips
プレビュー