Просмотр исходного кода

Merge pull request #1864 from visuddhinanda/laravel

add channel
visuddhinanda 2 лет назад
Родитель
Сommit
438e270dcd

+ 1 - 0
app/Console/Commands/MqPr.php

@@ -107,6 +107,7 @@ class MqPr extends Command
                                 'url'=>$link,
                                 'url'=>$link,
                                 'res_type'=> 'suggestion',
                                 'res_type'=> 'suggestion',
                                 'res_id'=> $prData->uid,
                                 'res_id'=> $prData->uid,
+                                'channel'=>$prData->channel->id,
                             ]);
                             ]);
             if($response->failed()){
             if($response->failed()){
                 Log::error('send notification failed');
                 Log::error('send notification failed');

+ 1 - 0
app/Http/Controllers/NotificationController.php

@@ -73,6 +73,7 @@ class NotificationController extends Controller
         $new->content = $request->get('content');
         $new->content = $request->get('content');
         $new->res_type = $request->get('res_type');
         $new->res_type = $request->get('res_type');
         $new->res_id = $request->get('res_id');
         $new->res_id = $request->get('res_id');
+        $new->channel = $request->get('channel');
         $new->save();
         $new->save();
 
 
         return $this->ok(new NotificationResource($new));
         return $this->ok(new NotificationResource($new));

+ 2 - 3
app/Http/Resources/NotificationResource.php

@@ -8,6 +8,7 @@ use App\Http\Api\UserApi;
 use App\Models\SentPr;
 use App\Models\SentPr;
 use App\Models\Sentence;
 use App\Models\Sentence;
 use App\Http\Api\PaliTextApi;
 use App\Http\Api\PaliTextApi;
+use App\Http\Api\ChannelApi;
 
 
 class NotificationResource extends JsonResource
 class NotificationResource extends JsonResource
 {
 {
@@ -35,6 +36,7 @@ class NotificationResource extends JsonResource
 
 
         switch ($this->res_type) {
         switch ($this->res_type) {
             case 'suggestion':
             case 'suggestion':
+                $data['channel'] = ChannelApi::getById($this->channel);
                 $prData = SentPr::where('uid',$this->res_id)->first();
                 $prData = SentPr::where('uid',$this->res_id)->first();
                 if($prData){
                 if($prData){
                     $link = config('mint.server.dashboard_base_path')."/article/para/{$prData->book_id}-{$prData->paragraph}";
                     $link = config('mint.server.dashboard_base_path')."/article/para/{$prData->book_id}-{$prData->paragraph}";
@@ -62,10 +64,7 @@ class NotificationResource extends JsonResource
                         $data['content'] = $content;
                         $data['content'] = $content;
                     }
                     }
                 }
                 }
-
-
                 break;
                 break;
-
             default:
             default:
                 # code...
                 # code...
                 break;
                 break;

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

@@ -0,0 +1,36 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddChannelInNotifications extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('notifications', function (Blueprint $table) {
+            //
+            $table->uuid('channel')->index();
+
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('notifications', function (Blueprint $table) {
+            //
+            $table->dropColumn('channel');
+
+        });
+    }
+}

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

@@ -0,0 +1,36 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddCorrelationInNotifications extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('notifications', function (Blueprint $table) {
+            //
+            $table->integer('correlation')->index()->default(10);
+
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('notifications', function (Blueprint $table) {
+            //
+            $table->dropColumn('correlation');
+
+        });
+    }
+}