increments('id'); $table->timestamps(); $table->boolean('seen'); $table->unsignedInteger('user_id')->index(); $table->unsignedInteger('actor_id')->index()->nullable(); // who did it $table->string('action'); // what happened, e.g.: favourited, mentioned, forked, commented $table->nullableMorphs('context'); // the action target or context $table->foreign('actor_id')->references('id')->on('users') ->onDelete('cascade'); $table->foreign('user_id')->references('id')->on('users') ->onDelete('cascade'); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('notifications'); } }