浏览代码

Add WebPush

Daniel Supernault 1 年之前
父节点
当前提交
4a1363b929
共有 4 个文件被更改,包括 426 次插入134 次删除
  1. 1 0
      composer.json
  2. 341 134
      composer.lock
  3. 48 0
      config/webpush.php
  4. 36 0
      database/migrations/2023_12_04_041631_create_push_subscriptions_table.php

+ 1 - 0
composer.json

@@ -20,6 +20,7 @@
 		"doctrine/dbal": "^3.0",
 		"intervention/image": "^2.4",
 		"jenssegers/agent": "^2.6",
+		"laravel-notification-channels/webpush": "^7.1",
 		"laravel/framework": "^10.0",
 		"laravel/helpers": "^1.1",
 		"laravel/horizon": "^5.0",

文件差异内容过多而无法显示
+ 341 - 134
composer.lock


+ 48 - 0
config/webpush.php

@@ -0,0 +1,48 @@
+<?php
+
+return [
+
+    /**
+     * These are the keys for authentication (VAPID).
+     * These keys must be safely stored and should not change.
+     */
+    'vapid' => [
+        'subject' => env('VAPID_SUBJECT'),
+        'public_key' => env('VAPID_PUBLIC_KEY'),
+        'private_key' => env('VAPID_PRIVATE_KEY'),
+        'pem_file' => env('VAPID_PEM_FILE'),
+    ],
+
+    /**
+     * This is model that will be used to for push subscriptions.
+     */
+    'model' => \NotificationChannels\WebPush\PushSubscription::class,
+
+    /**
+     * This is the name of the table that will be created by the migration and
+     * used by the PushSubscription model shipped with this package.
+     */
+    'table_name' => env('WEBPUSH_DB_TABLE', 'push_subscriptions'),
+
+    /**
+     * This is the database connection that will be used by the migration and
+     * the PushSubscription model shipped with this package.
+     */
+    'database_connection' => env('WEBPUSH_DB_CONNECTION', env('DB_CONNECTION', 'mysql')),
+
+    /**
+     * The Guzzle client options used by Minishlink\WebPush.
+     */
+    'client_options' => [],
+
+    /**
+     * Google Cloud Messaging.
+     *
+     * @deprecated
+     */
+    'gcm' => [
+        'key' => env('GCM_KEY'),
+        'sender_id' => env('GCM_SENDER_ID'),
+    ],
+
+];

+ 36 - 0
database/migrations/2023_12_04_041631_create_push_subscriptions_table.php

@@ -0,0 +1,36 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreatePushSubscriptionsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::connection(config('webpush.database_connection'))->create(config('webpush.table_name'), function (Blueprint $table) {
+            $table->bigIncrements('id');
+            $table->morphs('subscribable');
+            $table->string('endpoint', 500)->unique();
+            $table->string('public_key')->nullable();
+            $table->string('auth_token')->nullable();
+            $table->string('content_encoding')->nullable();
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::connection(config('webpush.database_connection'))->dropIfExists(config('webpush.table_name'));
+    }
+}

部分文件因为文件数量过多而无法显示