public function store() { try { $addModel = Input::json()->all(); //select the vendor name of the new selected vendor $vendorQueryResult = Vendor::find($addModel['vendor_id']); $newVendorName = $vendorQueryResult->name; //creates the new item, sets the properties, and saves it $addItem = new Item(); $addItem->description = $addModel['description']; $addItem->email_threshold = $addModel['email_threshold']; $addItem->item_url = $addModel['item_url']; $addItem->name = $addModel['name']; $addItem->on_order_quantity = $addModel['on_order_quantity']; $addItem->quantity = $addModel['quantity']; $addItem->vendor_id = $addModel['vendor_id']; $addItem->active = 1; $addItem->save(); $addItem->adjustmentQty = 0; $addItem->vendor_name = $newVendorName; return $addItem->toJson(); } catch (Exception $e) { return json_encode('{"error":{"text":' . $e->getMessage() . '}}'); } }