WatchApi.php 665 B

12345678910111213141516171819202122232425
  1. <?php
  2. namespace App\Http\Api;
  3. use App\Models\Like;
  4. class WatchApi{
  5. public static function change($resId,$from,$message){
  6. //发送站内信
  7. $watches = Like::where('type','watch')
  8. ->where('target_id',$resId)
  9. ->get();
  10. $notifications = [];
  11. foreach ($watches as $key => $watch) {
  12. $notifications[] = [
  13. 'from' => $from,
  14. 'to' => $watch->user_id,
  15. 'url' => $row['url'],
  16. 'content' => $message,
  17. 'res_type' => $watch->res_type,
  18. 'res_id' => $watch['res_id'],
  19. ];
  20. }
  21. }
  22. }