为什么值一直是 null,再次简化了流程测试,还是 null 
                            
                                                    
                        
                    
                    
  
                    
                    我想在每次留言和删除留言的时候统计留言的数量,然后更新到对应的字段里,之前发了一个问题,可能是流程没有表达清楚,回答的人很少,我现在简化一下问题
TestPsy.php
public function testreplies()
    {
        return $this->hasMany(TestReply::class);
    }
TestReply.php
public function testpsy()
    {
        return $this->belongsTo(TestPsy::class);
    }
controller
public function store(TestReplyRequest $request)
    {
        $testreply = TestReply::create($request->all());
        $testreply->testpsy->increment('reply_count', 1);
        session()->flash('success', '发布评论成功!');
        return redirect()->route('testreplies.show', $request->test_psy_id);
    }
$testreply->testpsy这个就是null,为什么?$testreply是有值的
          
                    
                    
          
          
                关于 LearnKu
              
                    
                    
                    
 
推荐文章: