Msg.php 837 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace App\Models;
  3. use Dcat\Admin\Traits\HasDateTimeFormatter;
  4. use Illuminate\Database\Eloquent\Model;
  5. class Msg extends Model
  6. {
  7. use HasDateTimeFormatter;
  8. protected $table = 'msg';
  9. protected $fillable = [
  10. 'type',
  11. 'user_id',
  12. 'to_user_id',
  13. 'title',
  14. 'content',
  15. 'product_id'
  16. ];
  17. public function type(){
  18. return [ 1 => '喜欢通知', 2 => '下载通知', 3 => '保存通知', 4 => '下架通知', 5 => '关注的人发了新作品', 6 => '系统通知'];
  19. }
  20. public function user(){
  21. return $this->hasOne(User::class,'id','to_user_id');
  22. }
  23. public function product(){
  24. return $this->hasOne(Product::class,'id','product_id');
  25. }
  26. public function read(){
  27. return $this->hasMany(MsgRead::class,'msg_id','id');
  28. }
  29. }