多态关联查询中使用 with ,morphWith 方法,不知道如何对查找的模型分别增加字段约束 
                            
                                                    
                        
                    
                    
  
                    
                    业务场景
获取 图片信息 当获取posts时 只取字段 id name ,当获取 users时 取 id name。
表结构
posts
    id - integer
    name - string
    status - integer
users
    id - integer
    name - string
    phone - int
    age - int
    status - int
images
    id - integer
    url - string
    imageable_id - integer
    imageable_type - string
多态关联
$imageInfos = images::with('imageable')->get();
- imageable 为 images模型的多态关联方法,此时取出的post 和 user 为所有表字段,虽然with方法 有 预加载列 ,但是多态,2个模型怎么分别加载呢,或者是有什么办法去限制吗?
 
          
                    
                    
            
          
          
                关于 LearnKu
              
                    
                    
                    
 
推荐文章: