@fleetbase/storefront-engine 0.3.23 → 0.3.25

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.
Files changed (112) hide show
  1. package/addon/adapters/catalog.js +1 -0
  2. package/addon/adapters/food-truck.js +1 -0
  3. package/addon/components/customer-panel/orders.hbs +7 -1
  4. package/addon/components/modals/assign-food-truck-catalogs.hbs +14 -0
  5. package/addon/components/modals/create-catalog.hbs +96 -0
  6. package/addon/components/modals/create-first-store.hbs +6 -1
  7. package/addon/components/modals/create-food-truck.hbs +69 -0
  8. package/addon/components/modals/manage-addons.js +1 -15
  9. package/addon/components/order-panel.hbs +2 -2
  10. package/addon/components/widget/customers.hbs +5 -5
  11. package/addon/components/widget/orders.hbs +7 -4
  12. package/addon/components/widget/orders.js +11 -1
  13. package/addon/controllers/catalogs/index.js +121 -0
  14. package/addon/controllers/food-trucks/index.js +100 -0
  15. package/addon/models/catalog-category.js +6 -0
  16. package/addon/models/catalog-hour.js +72 -0
  17. package/addon/models/catalog.js +45 -0
  18. package/addon/models/food-truck.js +47 -0
  19. package/addon/models/product.js +1 -0
  20. package/addon/routes/catalogs/index.js +22 -0
  21. package/addon/routes/catalogs.js +3 -0
  22. package/addon/routes/food-trucks/index.js +22 -0
  23. package/addon/routes/food-trucks.js +3 -0
  24. package/addon/routes.js +6 -0
  25. package/addon/serializers/catalog-category.js +15 -0
  26. package/addon/serializers/catalog.js +16 -0
  27. package/addon/serializers/food-truck.js +18 -0
  28. package/addon/serializers/product-variant.js +0 -1
  29. package/addon/services/storefront.js +1 -1
  30. package/addon/styles/storefront-engine.css +15 -5
  31. package/addon/templates/application.hbs +14 -0
  32. package/addon/templates/catalogs/index.hbs +46 -0
  33. package/addon/templates/catalogs.hbs +1 -0
  34. package/addon/templates/customers/index.hbs +1 -1
  35. package/addon/templates/food-trucks/index.hbs +52 -0
  36. package/addon/templates/food-trucks.hbs +1 -0
  37. package/addon/templates/networks/index.hbs +14 -2
  38. package/addon/templates/products/index/category/new.hbs +10 -3
  39. package/addon/templates/products/index/index.hbs +1 -2
  40. package/addon/templates/products/index.hbs +16 -2
  41. package/app/adapters/catalog.js +1 -0
  42. package/app/adapters/food-truck.js +1 -0
  43. package/app/components/modals/assign-food-truck-catalogs.js +1 -0
  44. package/app/components/modals/create-catalog.js +1 -0
  45. package/app/components/modals/create-food-truck.js +1 -0
  46. package/app/controllers/catalogs/index.js +1 -0
  47. package/app/controllers/food-trucks/index.js +1 -0
  48. package/app/models/catalog-category.js +1 -0
  49. package/app/models/catalog-hour.js +1 -0
  50. package/app/models/catalog.js +1 -0
  51. package/app/models/food-truck.js +1 -0
  52. package/app/routes/catalogs/index.js +1 -0
  53. package/app/routes/catalogs.js +1 -0
  54. package/app/routes/food-trucks/index.js +1 -0
  55. package/app/routes/food-trucks.js +1 -0
  56. package/app/serializers/catalog-category.js +1 -0
  57. package/app/serializers/catalog.js +1 -0
  58. package/app/serializers/food-truck.js +1 -0
  59. package/app/templates/catalogs/index.js +1 -0
  60. package/app/templates/catalogs.js +1 -0
  61. package/app/templates/food-trucks/index.js +1 -0
  62. package/app/templates/food-trucks.js +1 -0
  63. package/composer.json +1 -1
  64. package/extension.json +1 -1
  65. package/package.json +1 -1
  66. package/server/migrations/2025_01_30_042853_create_catalogs_table.php +41 -0
  67. package/server/migrations/2025_01_30_044728_create_catalog_category_products_table.php +35 -0
  68. package/server/migrations/2025_01_30_050611_create_food_trucks_table.php +72 -0
  69. package/server/migrations/2025_01_30_052157_create_catalog_subjects_table.php +54 -0
  70. package/server/migrations/2025_01_30_052402_create_catalog_hours_table.php +39 -0
  71. package/server/src/Auth/Schemas/Storefront.php +16 -0
  72. package/server/src/Console/Commands/PurgeExpiredCarts.php +49 -0
  73. package/server/src/Http/Controllers/CatalogCategoryController.php +13 -0
  74. package/server/src/Http/Controllers/CatalogController.php +13 -0
  75. package/server/src/Http/Controllers/CatalogHourController.php +13 -0
  76. package/server/src/Http/Controllers/FoodTruckController.php +13 -0
  77. package/server/src/Http/Controllers/v1/CatalogController.php +38 -0
  78. package/server/src/Http/Controllers/v1/CategoryController.php +1 -1
  79. package/server/src/Http/Controllers/v1/FoodTruckController.php +39 -0
  80. package/server/src/Http/Controllers/v1/OrderController.php +43 -0
  81. package/server/src/Http/Controllers/v1/ProductController.php +1 -1
  82. package/server/src/Http/Controllers/v1/ReviewController.php +8 -6
  83. package/server/src/Http/Filter/FoodTruckFilter.php +37 -0
  84. package/server/src/Http/Resources/Catalog.php +34 -0
  85. package/server/src/Http/Resources/CatalogCategory.php +38 -0
  86. package/server/src/Http/Resources/CatalogProduct.php +55 -0
  87. package/server/src/Http/Resources/FoodTruck.php +42 -0
  88. package/server/src/Http/Resources/Product.php +2 -1
  89. package/server/src/Models/AddonCategory.php +12 -0
  90. package/server/src/Models/Cart.php +6 -0
  91. package/server/src/Models/Catalog.php +213 -0
  92. package/server/src/Models/CatalogCategory.php +118 -0
  93. package/server/src/Models/CatalogHour.php +46 -0
  94. package/server/src/Models/CatalogProduct.php +25 -0
  95. package/server/src/Models/CatalogSubject.php +70 -0
  96. package/server/src/Models/FoodTruck.php +182 -0
  97. package/server/src/Models/Product.php +16 -1
  98. package/server/src/Notifications/StorefrontOrderCanceled.php +80 -121
  99. package/server/src/Notifications/StorefrontOrderCompleted.php +86 -131
  100. package/server/src/Notifications/StorefrontOrderCreated.php +29 -15
  101. package/server/src/Notifications/StorefrontOrderDriverAssigned.php +96 -130
  102. package/server/src/Notifications/StorefrontOrderEnroute.php +89 -129
  103. package/server/src/Notifications/StorefrontOrderNearby.php +103 -132
  104. package/server/src/Notifications/StorefrontOrderPreparing.php +89 -134
  105. package/server/src/Notifications/StorefrontOrderReadyForPickup.php +89 -134
  106. package/server/src/Observers/CatalogObserver.php +40 -0
  107. package/server/src/Observers/FoodTruckObserver.php +24 -0
  108. package/server/src/Observers/ProductObserver.php +3 -27
  109. package/server/src/Providers/StorefrontServiceProvider.php +7 -3
  110. package/server/src/Support/PushNotification.php +127 -0
  111. package/server/src/routes.php +15 -0
  112. package/translations/en-us.yaml +5 -0
@@ -0,0 +1,41 @@
1
+ <?php
2
+
3
+ use Fleetbase\Support\Utils;
4
+ use Illuminate\Database\Migrations\Migration;
5
+ use Illuminate\Database\Query\Expression;
6
+ use Illuminate\Database\Schema\Blueprint;
7
+ use Illuminate\Support\Facades\Schema;
8
+ use Illuminate\Support\Str;
9
+
10
+ return new class extends Migration {
11
+ /**
12
+ * Run the migrations.
13
+ */
14
+ public function up(): void
15
+ {
16
+ $databaseName = Utils::getFleetbaseDatabaseName();
17
+
18
+ Schema::connection(config('storefront.connection.db'))->create('catalogs', function (Blueprint $table) use ($databaseName) {
19
+ $table->bigIncrements('id');
20
+ $table->uuid('uuid')->unique()->default(Str::uuid()->toString());
21
+ $table->string('public_id')->unique()->nullable();
22
+ $table->foreignUuid('store_uuid')->nullable()->references('uuid')->on('stores')->onUpdate('CASCADE')->onDelete('SET NULL');
23
+ $table->foreignUuid('company_uuid')->nullable()->references('uuid')->on(new Expression($databaseName . '.companies'))->onUpdate('CASCADE')->onDelete('SET NULL');
24
+ $table->foreignUuid('created_by_uuid')->nullable()->references('uuid')->on(new Expression($databaseName . '.users'))->onUpdate('CASCADE')->onDelete('SET NULL');
25
+ $table->string('name');
26
+ $table->text('description')->nullable();
27
+ $table->string('status')->default('draft');
28
+ $table->json('meta')->nullable();
29
+ $table->timestamps();
30
+ $table->softDeletes();
31
+ });
32
+ }
33
+
34
+ /**
35
+ * Reverse the migrations.
36
+ */
37
+ public function down(): void
38
+ {
39
+ Schema::connection(config('storefront.connection.db'))->dropIfExists('catalogs');
40
+ }
41
+ };
@@ -0,0 +1,35 @@
1
+ <?php
2
+
3
+ use Fleetbase\Support\Utils;
4
+ use Illuminate\Database\Migrations\Migration;
5
+ use Illuminate\Database\Query\Expression;
6
+ use Illuminate\Database\Schema\Blueprint;
7
+ use Illuminate\Support\Facades\Schema;
8
+ use Illuminate\Support\Str;
9
+
10
+ return new class extends Migration {
11
+ /**
12
+ * Run the migrations.
13
+ */
14
+ public function up(): void
15
+ {
16
+ $databaseName = Utils::getFleetbaseDatabaseName();
17
+
18
+ Schema::connection(config('storefront.connection.db'))->create('catalog_category_products', function (Blueprint $table) use ($databaseName) {
19
+ $table->bigIncrements('id');
20
+ $table->uuid('uuid')->unique()->default(Str::uuid()->toString());
21
+ $table->foreignUuid('catalog_category_uuid')->nullable()->references('uuid')->on(new Expression($databaseName . '.categories'))->onUpdate('CASCADE')->onDelete('CASCADE');
22
+ $table->foreignUuid('product_uuid')->nullable()->references('uuid')->on('products')->onUpdate('CASCADE')->onDelete('CASCADE');
23
+ $table->timestamps();
24
+ $table->softDeletes();
25
+ });
26
+ }
27
+
28
+ /**
29
+ * Reverse the migrations.
30
+ */
31
+ public function down(): void
32
+ {
33
+ Schema::connection(config('storefront.connection.db'))->dropIfExists('catalog_category_products');
34
+ }
35
+ };
@@ -0,0 +1,72 @@
1
+ <?php
2
+
3
+ use Fleetbase\Support\Utils;
4
+ use Illuminate\Database\Migrations\Migration;
5
+ use Illuminate\Database\Query\Expression;
6
+ use Illuminate\Database\Schema\Blueprint;
7
+ use Illuminate\Support\Facades\Schema;
8
+ use Illuminate\Support\Str;
9
+
10
+ return new class extends Migration {
11
+ /**
12
+ * Run the migrations.
13
+ */
14
+ public function up(): void
15
+ {
16
+ // If your main Fleetbase DB name is needed for references:
17
+ $databaseName = Utils::getFleetbaseDatabaseName();
18
+
19
+ Schema::connection(config('storefront.connection.db'))->create('food_trucks', function (Blueprint $table) use ($databaseName) {
20
+ $table->bigIncrements('id');
21
+ $table->uuid('uuid')->unique()->default(Str::uuid()->toString());
22
+ $table->string('public_id')->unique()->nullable();
23
+ $table->foreignUuid('vehicle_uuid')
24
+ ->nullable()
25
+ ->references('uuid')
26
+ ->on(new Expression($databaseName . '.vehicles'))
27
+ ->onUpdate('CASCADE')
28
+ ->onDelete('SET NULL');
29
+ $table->foreignUuid('service_area_uuid')
30
+ ->nullable()
31
+ ->references('uuid')
32
+ ->on(new Expression($databaseName . '.service_areas'))
33
+ ->onUpdate('CASCADE')
34
+ ->onDelete('SET NULL');
35
+ $table->foreignUuid('zone_uuid')
36
+ ->nullable()
37
+ ->references('uuid')
38
+ ->on(new Expression($databaseName . '.zones'))
39
+ ->onUpdate('CASCADE')
40
+ ->onDelete('SET NULL');
41
+ $table->foreignUuid('store_uuid')
42
+ ->nullable()
43
+ ->references('uuid')
44
+ ->on('stores')
45
+ ->onUpdate('CASCADE')
46
+ ->onDelete('SET NULL');
47
+ $table->foreignUuid('company_uuid')
48
+ ->nullable()
49
+ ->references('uuid')
50
+ ->on(new Expression($databaseName . '.companies'))
51
+ ->onUpdate('CASCADE')
52
+ ->onDelete('SET NULL');
53
+ $table->foreignUuid('created_by_uuid')
54
+ ->nullable()
55
+ ->references('uuid')
56
+ ->on(new Expression($databaseName . '.users'))
57
+ ->onUpdate('CASCADE')
58
+ ->onDelete('SET NULL');
59
+ $table->string('status')->default('inactive');
60
+ $table->timestamps();
61
+ $table->softDeletes();
62
+ });
63
+ }
64
+
65
+ /**
66
+ * Reverse the migrations.
67
+ */
68
+ public function down(): void
69
+ {
70
+ Schema::connection(config('storefront.connection.db'))->dropIfExists('food_trucks');
71
+ }
72
+ };
@@ -0,0 +1,54 @@
1
+ <?php
2
+
3
+ use Fleetbase\Support\Utils;
4
+ use Illuminate\Database\Migrations\Migration;
5
+ use Illuminate\Database\Query\Expression;
6
+ use Illuminate\Database\Schema\Blueprint;
7
+ use Illuminate\Support\Facades\Schema;
8
+ use Illuminate\Support\Str;
9
+
10
+ return new class extends Migration {
11
+ /**
12
+ * Run the migrations.
13
+ */
14
+ public function up(): void
15
+ {
16
+ $databaseName = Utils::getFleetbaseDatabaseName();
17
+
18
+ Schema::connection(config('storefront.connection.db'))->create('catalog_subjects', function (Blueprint $table) use ($databaseName) {
19
+ $table->bigIncrements('id');
20
+ $table->uuid('uuid')->unique()->default(Str::uuid()->toString());
21
+ $table->foreignUuid('catalog_uuid')
22
+ ->references('uuid')
23
+ ->on('catalogs')
24
+ ->onUpdate('CASCADE')
25
+ ->onDelete('CASCADE');
26
+ $table->string('subject_type');
27
+ $table->uuid('subject_uuid');
28
+ $table->foreignUuid('company_uuid')
29
+ ->nullable()
30
+ ->references('uuid')
31
+ ->on(new Expression($databaseName . '.companies'))
32
+ ->onUpdate('CASCADE')
33
+ ->onDelete('SET NULL');
34
+
35
+ $table->foreignUuid('created_by_uuid')
36
+ ->nullable()
37
+ ->references('uuid')
38
+ ->on(new Expression($databaseName . '.users'))
39
+ ->onUpdate('CASCADE')
40
+ ->onDelete('SET NULL');
41
+ $table->timestamps();
42
+ $table->softDeletes();
43
+ $table->index(['subject_type', 'subject_uuid'], 'catalog_subject_idx');
44
+ });
45
+ }
46
+
47
+ /**
48
+ * Reverse the migrations.
49
+ */
50
+ public function down(): void
51
+ {
52
+ Schema::connection(config('storefront.connection.db'))->dropIfExists('catalog_subjects');
53
+ }
54
+ };
@@ -0,0 +1,39 @@
1
+ <?php
2
+
3
+ use Fleetbase\Support\Utils;
4
+ use Illuminate\Database\Migrations\Migration;
5
+ use Illuminate\Database\Schema\Blueprint;
6
+ use Illuminate\Support\Facades\Schema;
7
+ use Illuminate\Support\Str;
8
+
9
+ return new class extends Migration {
10
+ /**
11
+ * Run the migrations.
12
+ */
13
+ public function up(): void
14
+ {
15
+ $databaseName = Utils::getFleetbaseDatabaseName();
16
+
17
+ Schema::connection(config('storefront.connection.db'))->create('catalog_hours', function (Blueprint $table) {
18
+ $table->bigIncrements('id');
19
+ $table->uuid('uuid')->unique()->default(Str::uuid()->toString());
20
+ $table->foreignUuid('catalog_uuid')
21
+ ->references('uuid')->on('catalogs')
22
+ ->onUpdate('CASCADE')
23
+ ->onDelete('CASCADE');
24
+ $table->string('day_of_week');
25
+ $table->time('start')->nullable();
26
+ $table->time('end')->nullable();
27
+ $table->timestamps();
28
+ $table->softDeletes();
29
+ });
30
+ }
31
+
32
+ /**
33
+ * Reverse the migrations.
34
+ */
35
+ public function down(): void
36
+ {
37
+ Schema::connection(config('storefront.connection.db'))->dropIfExists('catalog_hours');
38
+ }
39
+ };
@@ -95,6 +95,22 @@ class Storefront
95
95
  'name' => 'store-hour',
96
96
  'actions' => [],
97
97
  ],
98
+ [
99
+ 'name' => 'catalog',
100
+ 'actions' => [],
101
+ ],
102
+ [
103
+ 'name' => 'catalog-category',
104
+ 'actions' => [],
105
+ ],
106
+ [
107
+ 'name' => 'catalog-hour',
108
+ 'actions' => [],
109
+ ],
110
+ [
111
+ 'name' => 'food-truck',
112
+ 'actions' => [],
113
+ ],
98
114
  [
99
115
  'name' => 'settings',
100
116
  'action' => ['import'],
@@ -0,0 +1,49 @@
1
+ <?php
2
+
3
+ namespace Fleetbase\Storefront\Console\Commands;
4
+
5
+ use Illuminate\Console\Command;
6
+ use Illuminate\Support\Facades\DB;
7
+
8
+ class PurgeExpiredCarts extends Command
9
+ {
10
+ /**
11
+ * The name and signature of the console command.
12
+ *
13
+ * @var string
14
+ */
15
+ protected $signature = 'storefront:purge-carts';
16
+
17
+ /**
18
+ * The console command description.
19
+ *
20
+ * @var string
21
+ */
22
+ protected $description = 'Permanently delete all expired carts from the database';
23
+
24
+ /**
25
+ * Execute the console command.
26
+ *
27
+ * @return int
28
+ */
29
+ public function handle()
30
+ {
31
+ $dbConnection = DB::connection(config('storefront.connection.db'));
32
+
33
+ // Disable foreign key checks for the correct connection
34
+ $dbConnection->statement('SET FOREIGN_KEY_CHECKS=0;');
35
+
36
+ // Delete expired carts
37
+ $dbDeletedCount = $dbConnection->table('carts')
38
+ ->where('expires_at', '<', now())
39
+ ->delete();
40
+
41
+ // Re-enable foreign key checks
42
+ $dbConnection->statement('SET FOREIGN_KEY_CHECKS=1;');
43
+
44
+ // Log output
45
+ $this->info("Successfully deleted {$dbDeletedCount} expired carts.");
46
+
47
+ return Command::SUCCESS;
48
+ }
49
+ }
@@ -0,0 +1,13 @@
1
+ <?php
2
+
3
+ namespace Fleetbase\Storefront\Http\Controllers;
4
+
5
+ class CatalogCategoryController extends StorefrontController
6
+ {
7
+ /**
8
+ * The resource to query.
9
+ *
10
+ * @var string
11
+ */
12
+ public $resource = 'catalog_category';
13
+ }
@@ -0,0 +1,13 @@
1
+ <?php
2
+
3
+ namespace Fleetbase\Storefront\Http\Controllers;
4
+
5
+ class CatalogController extends StorefrontController
6
+ {
7
+ /**
8
+ * The resource to query.
9
+ *
10
+ * @var string
11
+ */
12
+ public $resource = 'catalog';
13
+ }
@@ -0,0 +1,13 @@
1
+ <?php
2
+
3
+ namespace Fleetbase\Storefront\Http\Controllers;
4
+
5
+ class CatalogHourController extends StorefrontController
6
+ {
7
+ /**
8
+ * The resource to query.
9
+ *
10
+ * @var string
11
+ */
12
+ public $resource = 'catalog_category';
13
+ }
@@ -0,0 +1,13 @@
1
+ <?php
2
+
3
+ namespace Fleetbase\Storefront\Http\Controllers;
4
+
5
+ class FoodTruckController extends StorefrontController
6
+ {
7
+ /**
8
+ * The resource to query.
9
+ *
10
+ * @var string
11
+ */
12
+ public $resource = 'food_truck';
13
+ }
@@ -0,0 +1,38 @@
1
+ <?php
2
+
3
+ namespace Fleetbase\Storefront\Http\Controllers\v1;
4
+
5
+ use Fleetbase\Http\Controllers\Controller;
6
+ use Fleetbase\Storefront\Models\Catalog;
7
+ use Illuminate\Http\Request;
8
+
9
+ class CatalogController extends Controller
10
+ {
11
+ /**
12
+ * Query for Food Truck resources.
13
+ *
14
+ * @return \Illuminate\Http\Response
15
+ */
16
+ public function query(Request $request)
17
+ {
18
+ $limit = $request->input('limit', false);
19
+ $offset = $request->input('offset', false);
20
+ $results = [];
21
+
22
+ if (session('storefront_store')) {
23
+ $results = Catalog::queryWithRequest($request, function (&$query) use ($limit, $offset) {
24
+ $query->where('subject_uuid', session('storefront_store'));
25
+
26
+ if ($limit) {
27
+ $query->limit($limit);
28
+ }
29
+
30
+ if ($offset) {
31
+ $query->offset($offset);
32
+ }
33
+ });
34
+ }
35
+
36
+ return $results;
37
+ }
38
+ }
@@ -14,7 +14,7 @@ use Illuminate\Support\Facades\DB;
14
14
  class CategoryController extends Controller
15
15
  {
16
16
  /**
17
- * Query for Storefront Product resources.
17
+ * Query for Storefront Category resources.
18
18
  *
19
19
  * @return \Illuminate\Http\Response
20
20
  */
@@ -0,0 +1,39 @@
1
+ <?php
2
+
3
+ namespace Fleetbase\Storefront\Http\Controllers\v1;
4
+
5
+ use Fleetbase\Http\Controllers\Controller;
6
+ use Fleetbase\Storefront\Http\Resources\FoodTruck as FoodTruckResource;
7
+ use Fleetbase\Storefront\Models\FoodTruck;
8
+ use Illuminate\Http\Request;
9
+
10
+ class FoodTruckController extends Controller
11
+ {
12
+ /**
13
+ * Query for Food Truck resources.
14
+ *
15
+ * @return \Illuminate\Http\Response
16
+ */
17
+ public function query(Request $request)
18
+ {
19
+ $limit = $request->input('limit', false);
20
+ $offset = $request->input('offset', false);
21
+ $results = [];
22
+
23
+ if (session('storefront_store')) {
24
+ $results = FoodTruck::queryWithRequest($request, function (&$query) use ($limit, $offset) {
25
+ $query->where('store_uuid', session('storefront_store'));
26
+
27
+ if ($limit) {
28
+ $query->limit($limit);
29
+ }
30
+
31
+ if ($offset) {
32
+ $query->offset($offset);
33
+ }
34
+ });
35
+ }
36
+
37
+ return FoodTruckResource::collection($results);
38
+ }
39
+ }
@@ -0,0 +1,43 @@
1
+ <?php
2
+
3
+ namespace Fleetbase\Storefront\Http\Controllers\v1;
4
+
5
+ use Fleetbase\FleetOps\Models\Order;
6
+ use Fleetbase\Http\Controllers\Controller;
7
+ use Fleetbase\Storefront\Support\Storefront;
8
+ use Illuminate\Http\Request;
9
+
10
+ class OrderController extends Controller
11
+ {
12
+ /**
13
+ * Marks a pickup order as completed by "customer pickup".
14
+ *
15
+ * @return \Illuminate\Http\Response
16
+ */
17
+ public function completeOrderPickup(Request $request)
18
+ {
19
+ $customer = Storefront::getCustomerFromToken();
20
+ $order = Order::where('public_id', $request->order)->whereNull('deleted_at')->with(['customer'])->first();
21
+
22
+ if (!$order) {
23
+ return response()->apiError('No order found.');
24
+ }
25
+
26
+ // Confirm the completion is done by the customer
27
+ if ($order->customer_uuid !== $customer->uuid) {
28
+ return response()->apiError('Not authorized to pickup this order for completion.');
29
+ }
30
+
31
+ // Patch order config
32
+ Storefront::patchOrderConfig($order);
33
+
34
+ // update activity to completed
35
+ $order->updateStatus('completed');
36
+
37
+ return response()->json([
38
+ 'status' => 'ok',
39
+ 'order' => $order->public_id,
40
+ 'status' => $order->status,
41
+ ]);
42
+ }
43
+ }
@@ -2,8 +2,8 @@
2
2
 
3
3
  namespace Fleetbase\Storefront\Http\Controllers\v1;
4
4
 
5
+ use Fleetbase\FleetOps\Http\Resources\v1\DeletedResource;
5
6
  use Fleetbase\Http\Controllers\Controller;
6
- use Fleetbase\Http\Resources\v1\DeletedResource;
7
7
  use Fleetbase\Models\Category;
8
8
  use Fleetbase\Storefront\Http\Resources\Product as StorefrontProduct;
9
9
  use Fleetbase\Storefront\Models\Product;
@@ -33,8 +33,8 @@ class ReviewController extends Controller
33
33
  }
34
34
 
35
35
  if (session('storefront_store')) {
36
- $results = Review::queryWithRequest($request, function (&$query) use ($store, $limit, $offset) {
37
- $query->where('subject_uuid', $store->uuid);
36
+ $results = Review::queryWithRequest($request, function (&$query) use ($limit, $offset) {
37
+ $query->where('subject_uuid', session('storefront_store'));
38
38
 
39
39
  if ($limit) {
40
40
  $query->limit($limit);
@@ -176,8 +176,10 @@ class ReviewController extends Controller
176
176
  */
177
177
  public function create(CreateReviewRequest $request)
178
178
  {
179
- $customer = Storefront::getCustomerFromToken();
180
- $about = Storefront::about();
179
+ $customer = Storefront::getCustomerFromToken();
180
+ $about = Storefront::about();
181
+ $disk = $request->input('disk', config('filesystems.default'));
182
+ $bucket = $request->input('bucket', config('filesystems.disks.' . $disk . '.bucket', config('filesystems.disks.s3.bucket')));
181
183
 
182
184
  if (!$customer) {
183
185
  return response()->error('Not authorized to create reviews');
@@ -209,7 +211,7 @@ class ReviewController extends Controller
209
211
  $bucketPath = 'hyperstore/' . $about->public_id . '/review-photos/' . $review->uuid . '/' . File::randomFileName($extension);
210
212
 
211
213
  // upload file to path
212
- $upload = Storage::disk('s3')->put($bucketPath, base64_decode($data), 'public');
214
+ $upload = Storage::disk($disk)->put($bucketPath, base64_decode($data), 'public');
213
215
 
214
216
  // create the file
215
217
  $file = File::create([
@@ -222,7 +224,7 @@ class ReviewController extends Controller
222
224
  'extension' => $extension,
223
225
  'content_type' => $mimeType,
224
226
  'path' => $bucketPath,
225
- 'bucket' => config('filesystems.disks.s3.bucket'),
227
+ 'bucket' => $bucket,
226
228
  'type' => 'storefront_review_upload',
227
229
  'size' => Utils::getBase64ImageSize($data),
228
230
  ]);
@@ -0,0 +1,37 @@
1
+ <?php
2
+
3
+ namespace Fleetbase\Storefront\Http\Filter;
4
+
5
+ use Fleetbase\FleetOps\Http\Filter\OrderFilter as FleetOpsOrderFilter;
6
+ use Fleetbase\FleetOps\Models\ServiceArea;
7
+
8
+ class FoodTruckFilter extends FleetOpsOrderFilter
9
+ {
10
+ public function queryForInternal()
11
+ {
12
+ $this->builder->where('company_uuid', $this->session->get('company'));
13
+ }
14
+
15
+ public function storefront($storefront)
16
+ {
17
+ $this->builder->whereHas(
18
+ 'store',
19
+ function ($query) use ($storefront) {
20
+ $query->where('public_id', $storefront);
21
+ }
22
+ );
23
+ }
24
+
25
+ public function serviceArea(string $serviceAreaId)
26
+ {
27
+ $matchingServiceAreaIds = ServiceArea::on(config('fleetbase.connection.db'))
28
+ ->where(function ($query) use ($serviceAreaId) {
29
+ $query->where('public_id', $serviceAreaId)
30
+ ->orWhere('uuid', $serviceAreaId);
31
+ })
32
+ ->pluck('uuid')
33
+ ->toArray();
34
+
35
+ $this->builder->whereIn('service_area_uuid', $matchingServiceAreaIds);
36
+ }
37
+ }
@@ -0,0 +1,34 @@
1
+ <?php
2
+
3
+ namespace Fleetbase\Storefront\Http\Resources;
4
+
5
+ use Fleetbase\Http\Resources\FleetbaseResource;
6
+ use Fleetbase\Support\Http;
7
+
8
+ class Catalog extends FleetbaseResource
9
+ {
10
+ /**
11
+ * Transform the resource into an array.
12
+ *
13
+ * @param \Illuminate\Http\Request $request
14
+ *
15
+ * @return array
16
+ */
17
+ public function toArray($request)
18
+ {
19
+ return [
20
+ 'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
21
+ 'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
22
+ 'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
23
+ 'company_uuid' => $this->when(Http::isInternalRequest(), $this->company_uuid),
24
+ 'created_by_uuid' => $this->when(Http::isInternalRequest(), $this->created_by_uuid),
25
+ 'store_uuid' => $this->when(Http::isInternalRequest(), $this->store_uuid),
26
+ 'name' => $this->name,
27
+ 'description' => $this->description,
28
+ 'categories' => CatalogCategory::collection($this->categories ?? []),
29
+ 'status' => $this->status,
30
+ 'created_at' => $this->created_at,
31
+ 'updated_at' => $this->updated_at,
32
+ ];
33
+ }
34
+ }
@@ -0,0 +1,38 @@
1
+ <?php
2
+
3
+ namespace Fleetbase\Storefront\Http\Resources;
4
+
5
+ use Fleetbase\Http\Resources\FleetbaseResource;
6
+ use Fleetbase\Support\Http;
7
+
8
+ class CatalogCategory extends FleetbaseResource
9
+ {
10
+ /**
11
+ * Transform the resource into an array.
12
+ *
13
+ * @param \Illuminate\Http\Request $request
14
+ *
15
+ * @return array
16
+ */
17
+ public function toArray($request)
18
+ {
19
+ return [
20
+ 'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
21
+ 'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
22
+ 'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
23
+ 'company_uuid' => $this->when(Http::isInternalRequest(), $this->company_uuid),
24
+ 'parent_uuid' => $this->when(Http::isInternalRequest(), $this->parent_uuid),
25
+ 'store_uuid' => $this->when(Http::isInternalRequest(), $this->store_uuid),
26
+ 'owner_uuid' => $this->when(Http::isInternalRequest(), $this->owner_uuid),
27
+ 'name' => $this->name,
28
+ 'description' => $this->description,
29
+ 'tags' => $this->tags ?? [],
30
+ 'meta' => $this->meta ?? [],
31
+ 'products' => CatalogProduct::collection($this->products ?? []),
32
+ 'for' => $this->for,
33
+ 'order' => $this->order,
34
+ 'created_at' => $this->created_at,
35
+ 'updated_at' => $this->updated_at,
36
+ ];
37
+ }
38
+ }