1. I have just come into contact with TP5, and I am confused about the correlation model in the manual. I am here to ask for help~~ I hope you can get some answers. First post the error screenshot
#2. The model code is as follows
namespace app\index\model; use think\Model; class User extends Model{ public function group(){ //用户表 belongsToMany 用户组表(关联模型,中间表,关联id1,关联id2) return $this->belongsToMany('Group','auth_group_access','uid','group_id'); } }
3. The controller code is as follows
namespace app\index\controller; use think\Controller; use think\Db; use think\Request; use app\index\model\User as Usermodel; class User extends Controller{ //用户列表 public function index(){ $user = new Usermodel(); $data = $user->group; p($data);die; $this->assign('v',$data); return $this -> fetch(); } }
The id attribute does not exist. See how $notFound is obtained. Is there any missing parameters?