質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.46%
Laravel

LaravelとはTaylor Otwellによって開発された、オープンソースなPHPフレームワークです。Laravelはシンプルで表現的なシンタックスを持ち合わせており、ウェブアプリケーション開発の手助けをしてくれます。

PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

Q&A

0回答

1901閲覧

laravel8 jetstream で登録時にエラー及びログインできない

rnrnrnrn

総合スコア1

Laravel

LaravelとはTaylor Otwellによって開発された、オープンソースなPHPフレームワークです。Laravelはシンプルで表現的なシンタックスを持ち合わせており、ウェブアプリケーション開発の手助けをしてくれます。

PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

0グッド

0クリップ

投稿2021/05/17 05:47

編集2021/05/18 09:40

前提・実現したいこと

laravelにてデータベースの認証テーブル(user)を既存のテーブル(rooms)に変更しようと、他記事を参考に作成したのですが、
作成後、登録画面にて項目を入力し、登録ボタンを押すとエラーが発生します。
又、ログインも同様に項目を入力しログインボタンを押すと、
"入力した情報は記録と一致していない"とエラーメッセージが発生します。
既存のテーブルにはデータが入っている状態です。

入力項目は編集をしており
登録画面とログイン画面は、どちらもname(部屋番号)とpasswordとしております。

laravel初学者のため、説明不備な箇所があると思いますが、どうぞよろしくお願いいたします。

usersテーブルではない別のテーブルで認証をする↓
参考記事:https://qiita.com/n_oshiumi/items/a466ff2c8f20c3494538

発生している問題・エラーメッセージ

➀登録を押すとエラー
イメージ説明

➁ログインを押すと エラーメッセージ ```![イメージ説明](bdf666081347bd3f785ba2b5bf4b3afe.png) ### 該当のソースコード ```ここに言語を入力 php createNewUser.php */ public function create(array $input) { return Validator::make($input, [ 'room_name' => ['required', 'string', 'max:255'], // 'email' => ['required', 'string', 'email', 'max:255', 'unique:rooms'], 'password' => $this->passwordRules(), //['required', 'string', 'min:8', 'confirmed'], 'terms' => Jetstream::hasTermsAndPrivacyPolicyFeature() ? ['required', 'accepted'] : '', ])->validate(); return Room::create([ 'room_name' => $input['room_name'], // 'email' => $input['email'], 'password' => Hash::make($input['password']), ]); } }
namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Notifications\Notifiable; use Illuminate\Foundation\Auth\User as Authenticatable; class Room extends Authenticatable { // use HasApiTokens; // use HasProfilePhoto; use Notifiable; // use TwoFactorAuthenticatable; // use HasFactory; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'room_name', // 'email', 'password', ]; /** * The attributes that should be hidden for arrays. * * @var array */ protected $hidden = [ 'password', // 'remember_token', // 'two_factor_recovery_codes', // 'two_factor_secret', ]; /** * The attributes that should be cast to native types. * * @var array */ protected $casts = [ 'email_verified_at' => 'datetime', ]; /** * The accessors to append to the model's array form. * * @var array */ protected $appends = [ 'profile_photo_url', ]; public function hotel(){ return $this->belongsTO('App\Models\Hotel'); } }
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; class CreateRoomsTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('rooms', function (Blueprint $table) { // $table->string('name'); // $table->string('email')->unique(); // $table->timestamp('email_verified_at')->nullable(); $table->bigIncrements('id'); $table->string('password');//->nullable(); $table->string('room_name'); $table->unsignedBigInteger('hotel_id'); $table->timestamps(); $table->foreign('hotel_id')->references('id')->on('hotels'); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('rooms'); } }
namespace Database\Seeders; use Illuminate\Database\Seeder; use Illuminate\Support\Facades\DB; class RoomSeeder extends Seeder { /** * Run the database seeds. * * @return void */ public function run() { DB::table('rooms')->insert([ //1つめのホテル 25 [ 'id' => 1, 'room_name' => 'front', 'password' => '12345678', 'hotel_id' => 1 ], [ 'id' => 2, 'room_name' => '101', 'password' => '12345678', 'hotel_id' => 1 ], [ 'id' => 3, 'room_name' => '102', 'password' => '12345678', 'hotel_id' => 1 ], [ 'id' => 4, 'room_name' => '103', 'password' => '12345678', 'hotel_id' => 1 ], [ 'id' => 5, 'room_name' => '104', 'password' => '12345678', 'hotel_id' => 1 ], [ 'id' => 6, 'room_name' => '105', 'password' => '12345678', 'hotel_id' => 1 ],
login.blade <x-guest-layout> <x-jet-authentication-card> <x-slot name="logo"> <x-jet-authentication-card-logo /> </x-slot> <x-jet-validation-errors class="mb-4" /> @if (session('status')) <div class="mb-4 font-medium text-sm text-green-600"> {{ session('status') }} </div> @endif <form method="POST" action="{{ route('login') }}"> @csrf <div> <x-jet-label for="room_name" value="{{ __('部屋番号') }}" /> <x-jet-input id="room_name" class="block mt-1 w-full" type="text" name="room_name" :value="old('room_name')" required autofocus /> </div> <div class="mt-4"> <x-jet-label for="password" value="{{ __('Password') }}" /> <x-jet-input id="password" class="block mt-1 w-full" type="password" name="password" required autocomplete="current-password" /> </div> <div class="block mt-4"> <label for="remember_me" class="flex items-center"> <x-jet-checkbox id="remember_me" name="remember" /> <span class="ml-2 text-sm text-gray-600">{{ __('Remember me') }}</span> </label> </div> <div class="flex items-center justify-end mt-4"> @if (Route::has('password.request')) <a class="underline text-sm text-gray-600 hover:text-gray-900" href="{{ route('password.request') }}"> {{ __('Forgot your password?') }} </a> @endif <x-jet-button class="ml-4"> {{ __('Log in') }} </x-jet-button> </div> </form> </x-jet-authentication-card> </x-guest-layout>
register.blade <x-guest-layout> <x-jet-authentication-card> <x-slot name="logo"> <x-jet-authentication-card-logo /> </x-slot> <x-jet-validation-errors class="mb-4" /> <form method="POST" action="{{ route('register') }}"> @csrf <div> <x-jet-label for="room_name" value="{{ __('部屋番号') }}" /> <x-jet-input id="room_name" class="block mt-1 w-full" type="text" name="room_name" :value="old('room_name')" required autofocus autocomplete="room_name" /> </div> <div class="mt-4"> <x-jet-label for="password" value="{{ __('Password') }}" /> <x-jet-input id="password" class="block mt-1 w-full" type="password" name="password" required autocomplete="new-password" /> </div> <div class="mt-4"> <x-jet-label for="password_confirmation" value="{{ __('Confirm Password') }}" /> <x-jet-input id="password_confirmation" class="block mt-1 w-full" type="password" name="password_confirmation" required autocomplete="new-password" /> </div> @if (Laravel\Jetstream\Jetstream::hasTermsAndPrivacyPolicyFeature()) <div class="mt-4"> <x-jet-label for="terms"> <div class="flex items-center"> <x-jet-checkbox name="terms" id="terms"/> <div class="ml-2"> {!! __('I agree to the :terms_of_service and :privacy_policy', [ 'terms_of_service' => '<a target="_blank" href="'.route('terms.show').'" class="underline text-sm text-gray-600 hover:text-gray-900">'.__('Terms of Service').'</a>', 'privacy_policy' => '<a target="_blank" href="'.route('policy.show').'" class="underline text-sm text-gray-600 hover:text-gray-900">'.__('Privacy Policy').'</a>', ]) !!} </div> </div> </x-jet-label> </div> @endif <div class="flex items-center justify-end mt-4"> <a class="underline text-sm text-gray-600 hover:text-gray-900" href="{{ route('login') }}"> {{ __('Already registered?') }} </a> <x-jet-button class="ml-4"> {{ __('Register') }} </x-jet-button> </div> </form> </x-jet-authentication-card> </x-guest-layout>

試したこと

config/auth 既存テーブル名に変更

補足情報(FW/ツールのバージョンなど)

ここにより詳細な情報を記載してください。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.46%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問