【发布时间】:2020-04-29 07:20:37
【问题描述】:
Attribute.php
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Attribute extends Model
{
protected $guarded = [];
public function products()
{
return $this->belongsToMany('App\Product');
}
}
Product.php
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Product extends Model
{
protected $guarded = [];
public function attributes()
{
return $this->belongsToMany('App\Attribute');
}
}
我想为每一行获取value 列。
我应该在我的控制器中编写什么代码来访问这个value?
Laravel 版本:6.9.0
谢谢
【问题讨论】:
标签: php laravel many-to-many relationship