//数据库模型
public function articles()
{
return $this -> hasMany("App\Http\Model\Article","user_id","id");
}
//控制器
$user = User::select("id","name") -> withCount(['articles'])->find($uid);
dd($user);
//数据库模型
public function articles()
{
return $this -> hasMany("App\Http\Model\Article","user_id","id");
}
//控制器
$user = User::select("id","name") -> withCount(['articles'])->find($uid);
dd($user);