我有以下型号: - User:
id
- Product:
id
lid
user_id
- ProductCategories:
product_id
category_id
lid
- Category:
id
关系: 用户的hasMany产品 产品belongsToMany类别 我有一个用户和我有一个类别ID,我需要属于该类别的产品,按产品类别 这是最好的解决
我想从两个数据库表中显示我的数据,并且我得到错误消息为foreach()提供的无效参数。任何人都知道我如何解决这个错误? 注:我在laravel 这里新是我的控制器: $post = PostModel::find($post_id);
$comment = new CommentModel;
我PostModel: public function comments() {
ret