Adopt Laravel coding style
Shift automatically applies the Laravel coding style - which uses the PSR-2 coding style as a base with some minor additions. You may customize the adopted coding style by adding your own [PHP CS Fixer][1] `.php_cs` config file to your project root. Feel free to use [Shift's Laravel ruleset][2] to help you get started. [1]: https://github.com/FriendsOfPHP/PHP-CS-Fixer [2]: https://gist.github.com/laravel-shift/cab527923ed2a109dda047b97d53c200
This commit is contained in:
@@ -17,6 +17,7 @@ use Illuminate\Support\Facades\DB;
|
||||
class PredefinedKitCheckoutService
|
||||
{
|
||||
use AuthorizesRequests;
|
||||
|
||||
/**
|
||||
* @param Request $request, this function works with fields: checkout_at, expected_checkin, note
|
||||
* @param PredefinedKit $kit kit for checkout
|
||||
@@ -43,8 +44,8 @@ class PredefinedKitCheckoutService
|
||||
return ['errors' => $errors];
|
||||
}
|
||||
|
||||
$checkout_at = date("Y-m-d H:i:s");
|
||||
if (($request->filled('checkout_at')) && ($request->get('checkout_at') != date("Y-m-d"))) {
|
||||
$checkout_at = date('Y-m-d H:i:s');
|
||||
if (($request->filled('checkout_at')) && ($request->get('checkout_at') != date('Y-m-d'))) {
|
||||
$checkout_at = $request->get('checkout_at');
|
||||
}
|
||||
|
||||
@@ -59,7 +60,7 @@ class PredefinedKitCheckoutService
|
||||
|
||||
$errors = $this->saveToDb($user, $admin, $checkout_at, $expected_checkin, $errors, $assets_to_add, $license_seats_to_add, $consumables_to_add, $accessories_to_add, $note);
|
||||
|
||||
return ['errors' => $errors, 'assets' => $assets_to_add, 'accessories' => $accessories_to_add, 'consumables' => $consumables_to_add ];
|
||||
return ['errors' => $errors, 'assets' => $assets_to_add, 'accessories' => $accessories_to_add, 'consumables' => $consumables_to_add];
|
||||
} catch (ModelNotFoundException $e) {
|
||||
return ['errors' => [$e->getMessage()]];
|
||||
} catch (CheckoutNotAllowed $e) {
|
||||
@@ -79,12 +80,10 @@ class PredefinedKitCheckoutService
|
||||
$assets = $model->assets;
|
||||
$quantity = $model->pivot->quantity;
|
||||
foreach ($assets as $asset) {
|
||||
|
||||
if (
|
||||
$asset->availableForCheckout()
|
||||
&& !$asset->is($user)
|
||||
&& ! $asset->is($user)
|
||||
) {
|
||||
|
||||
$this->authorize('checkout', $asset);
|
||||
$quantity -= 1;
|
||||
$assets_to_add[] = $asset;
|
||||
@@ -116,6 +115,7 @@ class PredefinedKitCheckoutService
|
||||
$seats_to_add[] = $license->freeSeats[$i];
|
||||
}
|
||||
}
|
||||
|
||||
return $seats_to_add;
|
||||
}
|
||||
|
||||
@@ -127,6 +127,7 @@ class PredefinedKitCheckoutService
|
||||
$errors[] = trans('admin/kits/general.none_consumables', ['consumable'=> $consumable->name, 'qty' => $consumable->pivot->quantity]);
|
||||
}
|
||||
}
|
||||
|
||||
return $consumables;
|
||||
}
|
||||
|
||||
@@ -138,6 +139,7 @@ class PredefinedKitCheckoutService
|
||||
$errors[] = trans('admin/kits/general.none_accessory', ['accessory'=> $accessory->name, 'qty' => $accessory->pivot->quantity]);
|
||||
}
|
||||
}
|
||||
|
||||
return $accessories;
|
||||
}
|
||||
|
||||
@@ -169,7 +171,7 @@ class PredefinedKitCheckoutService
|
||||
$consumable->users()->attach($consumable->id, [
|
||||
'consumable_id' => $consumable->id,
|
||||
'user_id' => $admin->id,
|
||||
'assigned_to' => $user->id
|
||||
'assigned_to' => $user->id,
|
||||
]);
|
||||
event(new CheckoutableCheckedOut($consumable, $user, $admin, $note));
|
||||
}
|
||||
@@ -179,10 +181,11 @@ class PredefinedKitCheckoutService
|
||||
$accessory->users()->attach($accessory->id, [
|
||||
'accessory_id' => $accessory->id,
|
||||
'user_id' => $admin->id,
|
||||
'assigned_to' => $user->id
|
||||
'assigned_to' => $user->id,
|
||||
]);
|
||||
event(new CheckoutableCheckedOut($accessory, $user, $admin, $note));
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user