/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index($id = null) { if ($id == null) { $productTypes = ProductType::all(); } else { $productTypes = ProductType::find($id); } return $productTypes; }
public function productTypes() { echo '<pre>'; $arr = ProductType::all(); //print_r($arr); foreach ($arr as $t) { $prod = $t->products->toArray(); print_r($prod); } }