I have two MODEL
Product:
protected $visible = ['modules', 'id','name'];
public function modules()
{
return $this->hasMany('App\Model\Module','root','id');
}
Module:
protected $visible = [ 'id','name'];
In the controller:
$products = $this->product->with(['modules'])->get();
Output:
The front-end uses iview, I want to use iview's cascade selection
The format requirement is:
So I would like to ask, how can I elegantly modify the json key in LARAVEL to meet my needs?
Learning the map method will be a lot easier