EachLikeNotice.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace App\Listeners;
  3. use App\Events\EachLike;
  4. use App\Models\NoticeModel;
  5. use App\Models\User\UserModel;
  6. use App\Services\User\NoticeService;
  7. use Illuminate\Queue\InteractsWithQueue;
  8. use Illuminate\Contracts\Queue\ShouldQueue;
  9. class EachLikeNotice implements ShouldQueue
  10. {
  11. use InteractsWithQueue;
  12. /**
  13. * Create the event listener.
  14. *
  15. * @return void
  16. */
  17. public function __construct()
  18. {
  19. //
  20. }
  21. /**
  22. * Handle the event.
  23. *
  24. * @param EachLike $event
  25. * @return void
  26. */
  27. public function handle(EachLike $event)
  28. {
  29. if (
  30. $pUser = UserModel::where('uid', $event->isLikeUid)->first()
  31. ) {
  32. $ns = new NoticeService();
  33. $ns->thumbMe($event->uid, $pUser->partner_id);
  34. NoticeModel::create([
  35. 'uid' => $pUser->uid,
  36. 'type' => 14,
  37. 'title' => "收到新的心动",
  38. 'content' => "收到1条新的心动消息",
  39. ]);
  40. }
  41. }
  42. }