DocterMessage.php 996 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: zilongs
  5. * Date: 20-10-5
  6. * Time: 下午3:37
  7. */
  8. namespace App\Models;
  9. class DocterMessage extends BaseModel
  10. {
  11. protected $table='docter_messages';
  12. public $timestamps = true;
  13. public static function saveMessage($docter_id, $user_id, $type, $relation_id = 0, $param = [], $content = '')
  14. {
  15. if (empty($content)) {
  16. $content = config('config.docter_message_map')[$type] ?? '';
  17. $content = vsprintf($content, $param);
  18. }
  19. $add = [
  20. 'docter_id' => $docter_id,
  21. 'status' => 1,
  22. 'user_id' => $user_id,
  23. 'type' => $type,
  24. 'relation_id' => $relation_id,
  25. 'content' => $content,
  26. ];
  27. if (in_array($type, [1,4])) {
  28. $product_type = Order::where('id', $relation_id)->value('product_type');
  29. $add['order_type'] = $product_type;
  30. }
  31. DocterMessage::create($add);
  32. return true;
  33. }
  34. }