Create model and migration for notifications
ADD
app/Notification.php
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+class Notification extends Model {
+ public function space() {
+ return $this->belongsTo(Space::class);
+ }
+}

MODIFY
app/Space.php
app/Space.php
@@ -40,6 +40,10 @@ class Space extends Model {
return $this->hasMany(Import::class);
}
+ public function notifications() {
+ return $this->hasMany(Notification::class);
+ }
+
//
public function monthlyBalance($year, $month) {
$query = DB::selectOne('

ADD
database/migrations/2018_12_17_174821_create_notifications_table.php
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateNotificationsTable extends Migration {
+ public function up() {
+ Schema::create('notifications', function (Blueprint $table) {
+ $table->increments('id');
+ $table->unsignedInteger('space_id');
+ $table->unsignedInteger('user_id')->nullable();
+ $table->string('action');
+ $table->timestamps();
+
+ $table->foreign('space_id')->references('id')->on('spaces');
+ $table->foreign('user_id')->references('id')->on('users');
+ });
+ }
+
+ public function down() {
+ Schema::table('notifications', function ($table) {
+ $table->dropForeign('notifications_space_id_foreign');
+ $table->dropForeign('notifications_user_id_foreign');
+ });
+
+ Schema::dropIfExists('notifications');
+ }
+}

Create model and migration for notifications