123456789101112131415161718192021222324252627282930313233343536 |
- <?php
- namespace App\Models;
- use Dcat\Admin\Traits\HasDateTimeFormatter;
- use Illuminate\Database\Eloquent\Model;
- class Msg extends Model
- {
- use HasDateTimeFormatter;
- protected $table = 'msg';
- protected $fillable = [
- 'type',
- 'user_id',
- 'to_user_id',
- 'title',
- 'content',
- 'product_id'
- ];
- public function type(){
- return [ 1 => '喜欢通知', 2 => '下载通知', 3 => '保存通知', 4 => '下架通知', 5 => '关注的人发了新作品', 6 => '系统通知'];
- }
- public function user(){
- return $this->hasOne(User::class,'id','to_user_id');
- }
- public function product(){
- return $this->hasOne(Product::class,'id','product_id');
- }
- public function read(){
- return $this->hasMany(MsgRead::class,'msg_id','id');
- }
- }
|