From 4a3c6785c9f5ca7a5339cbc0c6eb38669322ea40 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 5 Oct 2016 20:20:51 +1100 Subject: [PATCH 1/5] Added predis/predis library for Redis Server --- composer.json | 3 ++- composer.lock | 68 ++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 61 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index 860b54e9e9..0681aa18b6 100644 --- a/composer.json +++ b/composer.json @@ -82,7 +82,8 @@ "barryvdh/laravel-debugbar": "~2.2", "fzaninotto/faker": "^1.5", "jaybizzle/laravel-crawler-detect": "1.*", - "codedge/laravel-selfupdater": "5.x-dev" + "codedge/laravel-selfupdater": "5.x-dev", + "predis/predis": "^1.1" }, "require-dev": { "phpunit/phpunit": "~4.0", diff --git a/composer.lock b/composer.lock index 3fede23c13..6c8036cdf5 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "09fda381adad88df20782277ade92809", - "content-hash": "77223af5b09a5e08bf323379fe8e3f24", + "hash": "f4bdaaf649c73d8e5b5d869b5d747296", + "content-hash": "f86c4c48a93a28dac4503651c52b86bd", "packages": [ { "name": "agmscode/omnipay-agms", @@ -1029,12 +1029,12 @@ "source": { "type": "git", "url": "https://github.com/codedge/laravel-selfupdater.git", - "reference": "ef8f30b8084d6b0c2d2587c0b621011a1515d250" + "reference": "b24b155fe0fcccf0ecfbc926a6c3043911418906" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/codedge/laravel-selfupdater/zipball/ef8f30b8084d6b0c2d2587c0b621011a1515d250", - "reference": "ef8f30b8084d6b0c2d2587c0b621011a1515d250", + "url": "https://api.github.com/repos/codedge/laravel-selfupdater/zipball/b24b155fe0fcccf0ecfbc926a6c3043911418906", + "reference": "b24b155fe0fcccf0ecfbc926a6c3043911418906", "shasum": "" }, "require": { @@ -1077,7 +1077,7 @@ "self-update", "update" ], - "time": "2016-08-21 16:46:12" + "time": "2016-09-21 12:43:00" }, { "name": "collizo4sky/omnipay-wepay", @@ -2184,7 +2184,7 @@ "shasum": null }, "type": "library", - "time": "2016-06-03 12:00:26" + "time": "2016-08-17 12:01:04" }, { "name": "google/apiclient", @@ -6386,6 +6386,56 @@ ], "time": "2015-05-01 07:00:55" }, + { + "name": "predis/predis", + "version": "v1.1.1", + "source": { + "type": "git", + "url": "https://github.com/nrk/predis.git", + "reference": "f0210e38881631afeafb56ab43405a92cafd9fd1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nrk/predis/zipball/f0210e38881631afeafb56ab43405a92cafd9fd1", + "reference": "f0210e38881631afeafb56ab43405a92cafd9fd1", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "require-dev": { + "phpunit/phpunit": "~4.8" + }, + "suggest": { + "ext-curl": "Allows access to Webdis when paired with phpiredis", + "ext-phpiredis": "Allows faster serialization and deserialization of the Redis protocol" + }, + "type": "library", + "autoload": { + "psr-4": { + "Predis\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Daniele Alessandri", + "email": "suppakilla@gmail.com", + "homepage": "http://clorophilla.net" + } + ], + "description": "Flexible and feature-complete Redis client for PHP and HHVM", + "homepage": "http://github.com/nrk/predis", + "keywords": [ + "nosql", + "predis", + "redis" + ], + "time": "2016-06-16 16:22:20" + }, { "name": "psr/http-message", "version": "1.0.1", @@ -6838,12 +6888,12 @@ "version": "1.0.4", "source": { "type": "git", - "url": "https://github.com/Superbalist/flysystem-google-storage.git", + "url": "https://github.com/Superbalist/flysystem-google-cloud-storage.git", "reference": "8ae35803a102ed6ce58aa87bf7534d4396513765" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Superbalist/flysystem-google-storage/zipball/8ae35803a102ed6ce58aa87bf7534d4396513765", + "url": "https://api.github.com/repos/Superbalist/flysystem-google-cloud-storage/zipball/8ae35803a102ed6ce58aa87bf7534d4396513765", "reference": "8ae35803a102ed6ce58aa87bf7534d4396513765", "shasum": "" }, From b013d118ababa48faf71d99e17c29c60db04c1f1 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 18 Oct 2016 19:31:21 +1100 Subject: [PATCH 2/5] Add Delete/Update methods into VendorAPIController --- app/Http/Controllers/VendorApiController.php | 70 ++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/app/Http/Controllers/VendorApiController.php b/app/Http/Controllers/VendorApiController.php index 3b0c2dadd7..024ec906da 100644 --- a/app/Http/Controllers/VendorApiController.php +++ b/app/Http/Controllers/VendorApiController.php @@ -1,5 +1,6 @@ itemResponse($vendor); } + + /** + * @SWG\Put( + * path="/vendors/{vendor_id}", + * tags={"vendor"}, + * summary="Update a vendor", + * @SWG\Parameter( + * in="body", + * name="body", + * @SWG\Schema(ref="#/definitions/Vendor") + * ), + * @SWG\Response( + * response=200, + * description="Update vendor", + * @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Vendor")) + * ), + * @SWG\Response( + * response="default", + * description="an ""unexpected"" error" + * ) + * ) + */ + + public function update(UpdateVendorRequest $request, $publicId) + { + if ($request->action) { + return $this->handleAction($request); + } + + $data = $request->input(); + $data['public_id'] = $publicId; + $vendor = $this->vendorRepo->save($data, $request->entity()); + + $vendor->load(['vendor_contacts']); + + return $this->itemResponse($vendor); + } + + + /** + * @SWG\Delete( + * path="/vendors/{vendor_id}", + * tags={"vendor"}, + * summary="Delete a vendor", + * @SWG\Parameter( + * in="body", + * name="body", + * @SWG\Schema(ref="#/definitions/Vendor") + * ), + * @SWG\Response( + * response=200, + * description="Delete vendor", + * @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Vendor")) + * ), + * @SWG\Response( + * response="default", + * description="an ""unexpected"" error" + * ) + * ) + */ + + public function destroy(UpdateVendorRequest $request) + { + $vendor = $request->entity(); + + $this->vendorRepo->delete($vendor); + + return $this->itemResponse($vendor); + } } From 151f9a0f7feb5499954bc0fa2c7916f1cac1893f Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 18 Oct 2016 20:26:30 +1100 Subject: [PATCH 3/5] fixed bug when saving vendorcontact --- app/Models/Vendor.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Models/Vendor.php b/app/Models/Vendor.php index 6a387e9246..a68cf42e2f 100644 --- a/app/Models/Vendor.php +++ b/app/Models/Vendor.php @@ -211,7 +211,8 @@ class Vendor extends EntityModel */ public function addVendorContact($data, $isPrimary = false) { - $publicId = isset($data['public_id']) ? $data['public_id'] : false; + //$publicId = isset($data['public_id']) ? $data['public_id'] : false; + $publicId = isset($data['public_id']) ? $data['public_id'] : (isset($data['id']) ? $data['id'] : false); if ($publicId && $publicId != '-1') { $contact = VendorContact::scope($publicId)->firstOrFail(); From 21f825defefd74fdd71c927eb5bdf0ebd5b06ab4 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 18 Oct 2016 20:28:27 +1100 Subject: [PATCH 4/5] fixed bug when saving vendorcontact --- app/Models/Vendor.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Models/Vendor.php b/app/Models/Vendor.php index a68cf42e2f..b58563f116 100644 --- a/app/Models/Vendor.php +++ b/app/Models/Vendor.php @@ -211,8 +211,8 @@ class Vendor extends EntityModel */ public function addVendorContact($data, $isPrimary = false) { - //$publicId = isset($data['public_id']) ? $data['public_id'] : false; - $publicId = isset($data['public_id']) ? $data['public_id'] : (isset($data['id']) ? $data['id'] : false); + $publicId = isset($data['public_id']) ? $data['public_id'] : false; + //$publicId = isset($data['public_id']) ? $data['public_id'] : (isset($data['id']) ? $data['id'] : false); if ($publicId && $publicId != '-1') { $contact = VendorContact::scope($publicId)->firstOrFail(); From ab2a636c23beb220c340be573f43228d7be825b7 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 18 Oct 2016 20:32:58 +1100 Subject: [PATCH 5/5] fixed bug when saving vendorcontact --- app/Models/Vendor.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Models/Vendor.php b/app/Models/Vendor.php index b58563f116..a68cf42e2f 100644 --- a/app/Models/Vendor.php +++ b/app/Models/Vendor.php @@ -211,8 +211,8 @@ class Vendor extends EntityModel */ public function addVendorContact($data, $isPrimary = false) { - $publicId = isset($data['public_id']) ? $data['public_id'] : false; - //$publicId = isset($data['public_id']) ? $data['public_id'] : (isset($data['id']) ? $data['id'] : false); + //$publicId = isset($data['public_id']) ? $data['public_id'] : false; + $publicId = isset($data['public_id']) ? $data['public_id'] : (isset($data['id']) ? $data['id'] : false); if ($publicId && $publicId != '-1') { $contact = VendorContact::scope($publicId)->firstOrFail();