Przeglądaj źródła

添加发送站内信代码

visuddhinanda 1 rok temu
rodzic
commit
8361ea26f8
1 zmienionych plików z 17 dodań i 2 usunięć
  1. 17 2
      api-v8/app/Http/Api/WatchApi.php

+ 17 - 2
api-v8/app/Http/Api/WatchApi.php

@@ -1,10 +1,25 @@
 <?php
 <?php
 namespace App\Http\Api;
 namespace App\Http\Api;
 
 
-use App\Models\Notification;
+use App\Models\Like;
 
 
 class WatchApi{
 class WatchApi{
-    public static function change($resId,$title,$message){
+    public static function change($resId,$from,$message){
         //发送站内信
         //发送站内信
+        $watches = Like::where('type','watch')
+                    ->where('target_id',$resId)
+                    ->get();
+        $notifications = [];
+        foreach ($watches as $key => $watch) {
+            $notifications[] = [
+                'from' => $from,
+                'to' => $watch->user_id,
+                'url' => $row['url'],
+                'content' => $message,
+                'res_type' => $watch->res_type,
+                'res_id' => $watch['res_id'],
+            ];
+
+        }
     }
     }
 }
 }