0
どうすれば設定できますか?学生と教師のレッスンスケジュールを作成しようとしています。レッスンスケジュールLaravel 2列が同じIDから来たときに3ウェイピボット
Schema::create('lessons', function (Blueprint $table) {
$table->increments('id');
$table->integer('status'); //0 - not started, 1 - completed, 2 - no show
$table->dateTime('start_at');
$table->dateTime('end_at');
$table->dateTime('started_at');
$table->dateTime('ended_at');
$table->string('unique_id')->unique();
$table->integer('teacher_id')->unsigned();
$table->foreign('teacher_id')
->references('id')->on('users')
->onUpdate('cascade')
->onDelete('cascade');
$table->integer('student_id')->unsigned();
$table->foreign('student_id')
->references('id')->on('users')
->onUpdate('cascade')
->onDelete('cascade');
$table->integer('completed');
$table->timestamps();
});
ため
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->text('photo_url')->nullable();
$table->string('firstname');
$table->string('lastname');
$table->string('username')->unique()->nullable();
$table->date('date_of_birth');
$table->string('email')->unique();
$table->string('password');
$table->timeTz('timezone');
$table->integer('is_active')->default(0);
$table->tinyInteger('verified')->default(0);
$table->string('email_token')->nullable();
$table->text('address');
$table->string('district');
$table->rememberToken();
$table->timestamps();
});
そして私は、このためのビューの上に自分のデータを表示したい場合。どのように私は様々なモデルに関係を追加し、私はそれらを表示するために表示するのですか?
私は、これは
嘆願を助けるbelongsToMany関係であると信じて!
どうすればよいですか?私はピボットを使用すると、多少あなたを制限し、物事をより複雑にしていると思い
だから、学生と教師のためのモデルはロールではない方がいいですか? – Didi
複数のタイプになることができる1人のユーザーがいると思いますか?それは完全に依存します。私は、生徒と教師が非常に異なる機能を持っていると想像しています。そのため、異なるユーザーに分かりやすくすることができます。 – ollieread