/**
  * 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;
 }
예제 #2
0
 public function productTypes()
 {
     echo '<pre>';
     $arr = ProductType::all();
     //print_r($arr);
     foreach ($arr as $t) {
         $prod = $t->products->toArray();
         print_r($prod);
     }
 }