@fleetbase/storefront-engine 0.3.25 → 0.3.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/composer.json +1 -1
- package/extension.json +1 -1
- package/package.json +1 -1
- package/server/src/Http/Controllers/v1/CheckoutController.php +4 -0
- package/server/src/Http/Controllers/v1/CustomerController.php +5 -1
- package/server/src/Http/Controllers/v1/StoreController.php +10 -0
- package/server/src/Http/Resources/ReviewCustomer.php +2 -0
- package/server/src/Models/Product.php +13 -1
- package/server/src/Models/Review.php +2 -2
- package/server/src/Observers/ProductObserver.php +17 -11
package/composer.json
CHANGED
package/extension.json
CHANGED
package/package.json
CHANGED
|
@@ -598,6 +598,7 @@ class CheckoutController extends Controller
|
|
|
598
598
|
{
|
|
599
599
|
$token = $request->input('token');
|
|
600
600
|
$transactionDetails = $request->input('transactionDetails', []); // optional details to be supplied about transaction
|
|
601
|
+
$notes = $request->input('notes');
|
|
601
602
|
|
|
602
603
|
// validate transaction details
|
|
603
604
|
if (!is_array($transactionDetails)) {
|
|
@@ -828,6 +829,7 @@ class CheckoutController extends Controller
|
|
|
828
829
|
'type' => 'storefront',
|
|
829
830
|
'status' => 'created',
|
|
830
831
|
'meta' => $orderMeta,
|
|
832
|
+
'notes' => $notes,
|
|
831
833
|
];
|
|
832
834
|
|
|
833
835
|
// if it's integrated vendor order apply to meta
|
|
@@ -879,6 +881,7 @@ class CheckoutController extends Controller
|
|
|
879
881
|
{
|
|
880
882
|
$token = $request->input('token');
|
|
881
883
|
$transactionDetails = $request->input('transactionDetails', []); // optional details to be supplied about transaction
|
|
884
|
+
$notes = $request->input('notes');
|
|
882
885
|
|
|
883
886
|
// validate transaction details
|
|
884
887
|
if (!is_array($transactionDetails)) {
|
|
@@ -1055,6 +1058,7 @@ class CheckoutController extends Controller
|
|
|
1055
1058
|
'adhoc' => $about->isOption('auto_dispatch'),
|
|
1056
1059
|
'type' => 'storefront',
|
|
1057
1060
|
'status' => 'created',
|
|
1061
|
+
'notes' => $notes,
|
|
1058
1062
|
];
|
|
1059
1063
|
|
|
1060
1064
|
// if it's integrated vendor order apply to meta
|
|
@@ -270,7 +270,11 @@ class CustomerController extends Controller
|
|
|
270
270
|
}
|
|
271
271
|
|
|
272
272
|
// update the contact
|
|
273
|
-
|
|
273
|
+
try {
|
|
274
|
+
$contact->update($input);
|
|
275
|
+
} catch (\Exception $e) {
|
|
276
|
+
return response()->apiError($e->getMessage());
|
|
277
|
+
}
|
|
274
278
|
|
|
275
279
|
// response the contact resource
|
|
276
280
|
return new Customer($contact);
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
namespace Fleetbase\Storefront\Http\Controllers\v1;
|
|
4
4
|
|
|
5
5
|
use Fleetbase\Http\Controllers\Controller;
|
|
6
|
+
use Fleetbase\Models\Category;
|
|
6
7
|
use Fleetbase\Storefront\Http\Resources\Gateway as GatewayResource;
|
|
7
8
|
use Fleetbase\Storefront\Http\Resources\Network as NetworkResource;
|
|
8
9
|
use Fleetbase\Storefront\Http\Resources\Product as ProductResource;
|
|
@@ -188,6 +189,15 @@ class StoreController extends Controller
|
|
|
188
189
|
->whereStatus('published')
|
|
189
190
|
->get();
|
|
190
191
|
|
|
192
|
+
// Search categories as well
|
|
193
|
+
$categories = Category::where(['company_uuid' => session('company'), 'for' => 'storefront_product'])->search($searchQuery)->get();
|
|
194
|
+
if ($categories) {
|
|
195
|
+
foreach ($categories as $category) {
|
|
196
|
+
$categoryProducts = Product::where('category_uuid', $category->uuid)->get();
|
|
197
|
+
$results = $results->merge($categoryProducts)->unique('uuid');
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
191
201
|
return ProductResource::collection($results);
|
|
192
202
|
}
|
|
193
203
|
|
|
@@ -25,6 +25,8 @@ class ReviewCustomer extends FleetbaseResource
|
|
|
25
25
|
'email' => $this->email,
|
|
26
26
|
'phone' => $this->phone,
|
|
27
27
|
'photo_url' => $this->photo_url,
|
|
28
|
+
'reviews_count' => $this->resource->reviews()->count(),
|
|
29
|
+
'uploads_count' => $this->resource->reviewUploads()->count(),
|
|
28
30
|
'slug' => $this->slug,
|
|
29
31
|
'created_at' => $this->created_at,
|
|
30
32
|
'updated_at' => $this->updated_at,
|
|
@@ -48,12 +48,19 @@ class Product extends StorefrontModel
|
|
|
48
48
|
*/
|
|
49
49
|
protected $table = 'products';
|
|
50
50
|
|
|
51
|
+
/**
|
|
52
|
+
* The default database connection to use.
|
|
53
|
+
*
|
|
54
|
+
* @var string
|
|
55
|
+
*/
|
|
56
|
+
protected $connection = 'storefront';
|
|
57
|
+
|
|
51
58
|
/**
|
|
52
59
|
* These attributes that can be queried.
|
|
53
60
|
*
|
|
54
61
|
* @var array
|
|
55
62
|
*/
|
|
56
|
-
protected $searchableColumns = ['name', 'description'];
|
|
63
|
+
protected $searchableColumns = ['name', 'description', 'tags'];
|
|
57
64
|
|
|
58
65
|
/**
|
|
59
66
|
* The attributes that are mass assignable.
|
|
@@ -383,6 +390,11 @@ class Product extends StorefrontModel
|
|
|
383
390
|
$option['additional_cost'] = Utils::numbersOnly($option['additional_cost']);
|
|
384
391
|
}
|
|
385
392
|
|
|
393
|
+
// additional cost can never be null
|
|
394
|
+
if ($option['additional_cost'] === null) {
|
|
395
|
+
$option['additional_cost'] = 0;
|
|
396
|
+
}
|
|
397
|
+
|
|
386
398
|
$productVariantOptionInput = Arr::except($option, ['uuid', 'created_at', 'updated_at']);
|
|
387
399
|
ProductVariantOption::where('uuid', $option['uuid'])->update($productVariantOptionInput);
|
|
388
400
|
continue;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
namespace Fleetbase\Storefront\Models;
|
|
4
4
|
|
|
5
|
-
use Fleetbase\FleetOps\Models\Contact;
|
|
6
5
|
use Fleetbase\Models\File;
|
|
6
|
+
use Fleetbase\Models\User;
|
|
7
7
|
use Fleetbase\Traits\HasApiModelBehavior;
|
|
8
8
|
use Fleetbase\Traits\HasPublicid;
|
|
9
9
|
use Fleetbase\Traits\HasUuid;
|
|
@@ -84,7 +84,7 @@ class Review extends StorefrontModel
|
|
|
84
84
|
*/
|
|
85
85
|
public function customer()
|
|
86
86
|
{
|
|
87
|
-
return $this->setConnection(config('fleetbase.connection.db'))->belongsTo(
|
|
87
|
+
return $this->setConnection(config('fleetbase.connection.db'))->belongsTo(Customer::class);
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
/**
|
|
@@ -4,6 +4,7 @@ namespace Fleetbase\Storefront\Observers;
|
|
|
4
4
|
|
|
5
5
|
use Fleetbase\Models\File;
|
|
6
6
|
use Fleetbase\Storefront\Models\Product;
|
|
7
|
+
use Illuminate\Support\Facades\Log;
|
|
7
8
|
use Illuminate\Support\Facades\Request;
|
|
8
9
|
|
|
9
10
|
class ProductObserver
|
|
@@ -15,20 +16,25 @@ class ProductObserver
|
|
|
15
16
|
*/
|
|
16
17
|
public function saved(Product $product): void
|
|
17
18
|
{
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
try {
|
|
20
|
+
$addonCategories = Request::input('product.addon_categories', []);
|
|
21
|
+
$variants = Request::input('product.variants', []);
|
|
22
|
+
$files = Request::input('product.files', []);
|
|
21
23
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
// save addon categories
|
|
25
|
+
$product->setAddonCategories($addonCategories);
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
// save product variants
|
|
28
|
+
$product->setProductVariants($variants);
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
// set keys on files
|
|
31
|
+
foreach ($files as $file) {
|
|
32
|
+
$fileRecord = File::where('uuid', $file['uuid'])->first();
|
|
33
|
+
$fileRecord->setKey($product);
|
|
34
|
+
}
|
|
35
|
+
} catch (\Exception $e) {
|
|
36
|
+
Log::error($e->getMessage());
|
|
37
|
+
throw $e;
|
|
32
38
|
}
|
|
33
39
|
}
|
|
34
40
|
}
|