コード例 #1
0
ファイル: OrderController.php プロジェクト: MangTomas23/tgm
 public function query()
 {
     $input = Input::all();
     $response = array();
     $response['product'] = Product::where('name', 'like', $input['query'] . '%')->orderBy('name')->first();
     $response['supplier'] = Supplier::find($response['product']->supplier_id);
     $response['category'] = ProductCategory::find($response['product']->product_category_id);
     $response['boxes'] = Box::where('product_id', $response['product']->id)->get();
     $response['stocks'] = array();
     foreach ($response['boxes'] as $box) {
         $stock = Box::countStock($box->id);
         array_push($response['stocks'], $stock);
     }
     return $response;
 }