Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions scripts/pest-bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,10 +361,13 @@ function now($tz = null): Illuminate\Support\Carbon
});
}

if (class_exists('Illuminate\Http\Request') && !Illuminate\Http\Request::hasMacro('array')) {
Illuminate\Http\Request::macro('array', function (string $parameter, array $default = []): array {
return (array) $this->input($parameter, $default);
});
// `array` stays until released fleetops, which these tests load, moves to `inputArray`.
foreach (['inputArray', 'array'] as $macro) {
if (class_exists('Illuminate\Http\Request') && !Illuminate\Http\Request::hasMacro($macro) && !method_exists('Illuminate\Http\Request', $macro)) {
Illuminate\Http\Request::macro($macro, function (string $parameter, array $default = []): array {
return (array) $this->input($parameter, $default);
});
}
}

if (class_exists('Illuminate\Http\Request') && !Illuminate\Http\Request::hasMacro('or')) {
Expand Down
4 changes: 2 additions & 2 deletions server/src/Http/Controllers/AddonCategoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function createRecord(Request $request)
$this->validateRequest($request);

$record = $this->model->createRecordFromRequest($request, null, function (&$request, AddonCategory &$addonCategory) {
$addons = $request->array('addonCategory.addons');
$addons = $request->inputArray('addonCategory.addons');
$addonCategory->setAddons($addons);
});

Expand Down Expand Up @@ -77,7 +77,7 @@ public function updateRecord(Request $request, string $id)
try {
$this->validateRequest($request);
$record = $this->model->updateRecordFromRequest($request, $id, function (&$request, AddonCategory &$addonCategory) {
$addons = $request->array('addonCategory.addons');
$addons = $request->inputArray('addonCategory.addons');
$addonCategory->setAddons($addons);
});

Expand Down
4 changes: 2 additions & 2 deletions server/src/Http/Controllers/CatalogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public function assignSubjects(string $id, Request $request)
return response()->error('Catalog not found.', 404);
}

$this->syncSubjects($catalog, Store::class, $request->array('stores'));
$this->syncSubjects($catalog, FoodTruck::class, $request->array('food_trucks'));
$this->syncSubjects($catalog, Store::class, $request->inputArray('stores'));
$this->syncSubjects($catalog, FoodTruck::class, $request->inputArray('food_trucks'));

$catalog->load(['categories.products', 'hours', 'assignments.subject']);

Expand Down
2 changes: 1 addition & 1 deletion server/src/Http/Controllers/MetricsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function all(Request $request)
{
$start = $request->date('start')?->startOfDay();
$end = $request->date('end')?->endOfDay();
$discover = $request->array('discover', []);
$discover = $request->inputArray('discover', []);

try {
$data = Metrics::forCompany($request->user()->company, $start, $end)->with($discover)->get();
Expand Down
16 changes: 8 additions & 8 deletions server/src/Http/Controllers/NetworkController.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function sendInvites(string $id, NetworkActionRequest $request)
return response()->error('This category is not one of the network\'s categories.', 422);
}

$recipients = collect($request->array('recipients'))->filter(fn ($email) => is_string($email) && filter_var($email, FILTER_VALIDATE_EMAIL))->map(fn ($email) => strtolower(trim($email)))->unique()->values();
$recipients = collect($request->inputArray('recipients'))->filter(fn ($email) => is_string($email) && filter_var($email, FILTER_VALIDATE_EMAIL))->map(fn ($email) => strtolower(trim($email)))->unique()->values();
$expiresInDays = $request->input('expires_in_days');
$meta = array_filter([
'status' => 'pending',
Expand Down Expand Up @@ -579,8 +579,8 @@ public function addStores(string $id, NetworkActionRequest $request)
return response()->error('Network not found.', 404);
}

$stores = collect($request->array('stores'))->filter(fn ($storeId) => is_string($storeId))->values();
$remove = collect($request->array('remove'))->filter(fn ($storeId) => is_string($storeId))->values();
$stores = collect($request->inputArray('stores'))->filter(fn ($storeId) => is_string($storeId))->values();
$remove = collect($request->inputArray('remove'))->filter(fn ($storeId) => is_string($storeId))->values();
$members = NetworkStore::where('network_uuid', $network->uuid)->whereIn('store_uuid', $stores)->pluck('store_uuid');

// Existing members (which may belong to other companies) are left as they are; new
Expand Down Expand Up @@ -742,7 +742,7 @@ public function suspendStores(string $id, NetworkActionRequest $request)
return response()->error('Network not found.', 404);
}

return $this->setMembershipStatus($network, $request->array('stores'), NetworkStore::STATUS_SUSPENDED);
return $this->setMembershipStatus($network, $request->inputArray('stores'), NetworkStore::STATUS_SUSPENDED);
}

/**
Expand All @@ -758,7 +758,7 @@ public function reinstateStores(string $id, NetworkActionRequest $request)
return response()->error('Network not found.', 404);
}

return $this->setMembershipStatus($network, $request->array('stores'), NetworkStore::STATUS_ACTIVE);
return $this->setMembershipStatus($network, $request->inputArray('stores'), NetworkStore::STATUS_ACTIVE);
}

/**
Expand All @@ -775,7 +775,7 @@ public function approveStores(string $id, NetworkActionRequest $request)
return response()->error('Network not found.', 404);
}

$stores = $request->array('stores');
$stores = $request->inputArray('stores');
$this->closeAwaitingInvitations($network->uuid, $stores, 'accepted', 'approved_at');

return $this->setMembershipStatus($network, $stores, NetworkStore::STATUS_ACTIVE);
Expand All @@ -795,7 +795,7 @@ public function rejectStores(string $id, NetworkActionRequest $request)
return response()->error('Network not found.', 404);
}

$stores = $request->array('stores');
$stores = $request->inputArray('stores');
$this->closeAwaitingInvitations($network->uuid, $stores, 'rejected', 'rejected_at');

$removed = NetworkStore::where('network_uuid', $network->uuid)
Expand Down Expand Up @@ -898,7 +898,7 @@ public function removeStores(string $id, NetworkActionRequest $request)
return response()->error('Network not found.', 404);
}

$stores = $request->array('stores');
$stores = $request->inputArray('stores');

// delete each
foreach ($stores as $storeId) {
Expand Down
2 changes: 1 addition & 1 deletion server/src/Http/Controllers/ProductController.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public function processImports(Request $request)
*/
public function createEntities(Request $request)
{
$productIds = $request->array('products');
$productIds = $request->inputArray('products');
$products = Product::whereIn('uuid', $productIds)->get();
$entities = [];

Expand Down
2 changes: 1 addition & 1 deletion server/src/Observers/NetworkObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class NetworkObserver
public function updating(Network $network): void
{
$network->flushAttributesCache();
$alertable = Request::array('network.alertable');
$alertable = Request::inputArray('network.alertable');

// set alertables to public_id
$network->alertable = collect($alertable)->mapWithKeys(
Expand Down