How can i set up this, i'm trying to build a student and teacher lesson schedule, here is my code.
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();
});
And then for the lesson schedules
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();
});
if i want to display my data on the view for this. How do i add the relations to the various models and how do i display them to view.
I believe this is a belongsToMany relations
Pleas help!
how do i do this?
Not sure if i clear enough
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2x4xCVQ
via IFTTT
Aucun commentaire:
Enregistrer un commentaire