diff --git a/app/Admin/Controllers/NoticeController.php b/app/Admin/Controllers/NoticeController.php
new file mode 100644
index 0000000..646a0e9
--- /dev/null
+++ b/app/Admin/Controllers/NoticeController.php
@@ -0,0 +1,30 @@
+validate(request(), [
+ 'title' => 'required|string',
+ 'content' => 'required|string'
+ ]);
+
+ $notice = \App\Notice::create(request(['title', 'content']));
+ dispatch(new \App\Jobs\SendMessage($notice));
+
+ return redirect("/admin/notices");
+ }
+}
\ No newline at end of file
diff --git a/app/Http/Controllers/NoticeController.php b/app/Http/Controllers/NoticeController.php
new file mode 100644
index 0000000..8fc8bea
--- /dev/null
+++ b/app/Http/Controllers/NoticeController.php
@@ -0,0 +1,19 @@
+notices;
+
+ return view('notice/index', compact('notices'));
+ }
+}
diff --git a/app/Jobs/SendMessage.php b/app/Jobs/SendMessage.php
new file mode 100644
index 0000000..71d9d44
--- /dev/null
+++ b/app/Jobs/SendMessage.php
@@ -0,0 +1,41 @@
+notice = $notice;
+ }
+
+ /**
+ * Execute the job.
+ *
+ * @return void
+ */
+ public function handle()
+ {
+ // 通知每个用户系统消息
+ $users = \App\User::all();
+ foreach ($users as $user) {
+ $user->addNotice($this->notice);
+ }
+ }
+}
diff --git a/app/Notice.php b/app/Notice.php
new file mode 100644
index 0000000..2689360
--- /dev/null
+++ b/app/Notice.php
@@ -0,0 +1,10 @@
+stars()->where('star_id', $uid)->count();
}
+
+ // 用户收到的通知
+ public function notices()
+ {
+ return $this->belongsToMany(\App\Notice::class, 'user_notice', 'user_id'
+ , 'notice_id')->withPivot(['user_id', 'notice_id']);
+ }
+
+ // 给用户增加通知
+ public function addNotice($notice)
+ {
+ return $this->notices()->save($notice);
+ }
}
\ No newline at end of file
diff --git a/database/migrations/2019_11_04_110156_create_notice_table.php b/database/migrations/2019_11_04_110156_create_notice_table.php
new file mode 100644
index 0000000..b0bd9c3
--- /dev/null
+++ b/database/migrations/2019_11_04_110156_create_notice_table.php
@@ -0,0 +1,42 @@
+increments('id');
+ $table->string('title', 50)->default("");
+ $table->string('content', 1000)->default("");
+ $table->timestamps();
+ });
+
+ Schema::create('user_notice', function (Blueprint $table) {
+ $table->increments('id');
+ $table->integer('user_id')->default(0);
+ $table->integer('notice_id')->default(0);
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ //
+ Schema::dropIfExists('notices');
+ Schema::dropIfExists('user_notice');
+ }
+}
diff --git a/database/migrations/2019_11_04_140746_create_jobs_table.php b/database/migrations/2019_11_04_140746_create_jobs_table.php
new file mode 100644
index 0000000..acd2597
--- /dev/null
+++ b/database/migrations/2019_11_04_140746_create_jobs_table.php
@@ -0,0 +1,38 @@
+bigIncrements('id');
+ $table->string('queue');
+ $table->longText('payload');
+ $table->unsignedTinyInteger('attempts');
+ $table->unsignedInteger('reserved_at')->nullable();
+ $table->unsignedInteger('available_at');
+ $table->unsignedInteger('created_at');
+
+ $table->index(['queue', 'reserved_at']);
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::dropIfExists('jobs');
+ }
+}
diff --git a/resources/views/admin/notice/create.blade.php b/resources/views/admin/notice/create.blade.php
new file mode 100644
index 0000000..89d88cf
--- /dev/null
+++ b/resources/views/admin/notice/create.blade.php
@@ -0,0 +1,42 @@
+@extends("admin.layout.main")
+
+@section("content")
+
+ 增加通知
+ 通知列表
+
+
+
+
+
+ @foreach($notices as $notice)
+ #
+ 通知名称
+ 操作
+
+
+ @endforeach
+
+ {{$notice->id}}
+ {{$notice->title}}
+
+
{{$notice->content}}
+