-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into testing/consumable-ui
- Loading branch information
Showing
328 changed files
with
3,708 additions
and
2,081 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
use App\Models\Accessory; | ||
use App\Models\Company; | ||
use App\Models\User; | ||
use Illuminate\Http\JsonResponse; | ||
use Illuminate\Support\Facades\Auth; | ||
use Carbon\Carbon; | ||
use Illuminate\Support\Facades\DB; | ||
|
@@ -184,39 +185,33 @@ public function accessory_detail($id) | |
|
||
|
||
/** | ||
* Display the specified resource. | ||
* Get the list of checkouts for a specific accessory | ||
* | ||
* @author [A. Gianotto] [<[email protected]>] | ||
* @since [v4.0] | ||
* @param int $id | ||
* @return \Illuminate\Http\Response | ||
* @return | array | ||
*/ | ||
public function checkedout($id, Request $request) | ||
public function checkedout(Request $request, $id) | ||
{ | ||
$this->authorize('view', Accessory::class); | ||
|
||
$accessory = Accessory::with('lastCheckout')->findOrFail($id); | ||
|
||
$offset = request('offset', 0); | ||
$limit = request('limit', 50); | ||
|
||
$accessory_checkouts = $accessory->checkouts; | ||
$total = $accessory_checkouts->count(); | ||
|
||
if ($total < $offset) { | ||
$offset = 0; | ||
} | ||
|
||
$accessory_checkouts = $accessory->checkouts()->skip($offset)->take($limit)->get(); | ||
// Total count of all checkouts for this asset | ||
$accessory_checkouts = $accessory->checkouts(); | ||
|
||
// Check for search text in the request | ||
if ($request->filled('search')) { | ||
|
||
$accessory_checkouts = $accessory->checkouts()->TextSearch($request->input('search')) | ||
->get(); | ||
$total = $accessory_checkouts->count(); | ||
$accessory_checkouts = $accessory_checkouts->TextSearch($request->input('search')); | ||
} | ||
|
||
return (new AccessoriesTransformer)->transformCheckedoutAccessory($accessory, $accessory_checkouts, $total); | ||
$total = $accessory_checkouts->count(); | ||
$accessory_checkouts = $accessory_checkouts->skip($offset)->take($limit)->get(); | ||
|
||
return (new AccessoriesTransformer)->transformCheckedoutAccessory($accessory_checkouts, $total); | ||
} | ||
|
||
|
||
|
@@ -227,7 +222,7 @@ public function checkedout($id, Request $request) | |
* @since [v4.0] | ||
* @param \App\Http\Requests\ImageUploadRequest $request | ||
* @param int $id | ||
* @return \Illuminate\Http\Response | ||
* @return \Illuminate\Http\JsonResponse | ||
*/ | ||
public function update(ImageUploadRequest $request, $id) | ||
{ | ||
|
@@ -249,7 +244,7 @@ public function update(ImageUploadRequest $request, $id) | |
* @author [A. Gianotto] [<[email protected]>] | ||
* @since [v4.0] | ||
* @param int $id | ||
* @return \Illuminate\Http\Response | ||
* @return \Illuminate\Http\JsonResponse | ||
*/ | ||
public function destroy($id) | ||
{ | ||
|
@@ -284,14 +279,17 @@ public function checkout(AccessoryCheckoutRequest $request, Accessory $accessory | |
$accessory->checkout_qty = $request->input('checkout_qty', 1); | ||
|
||
for ($i = 0; $i < $accessory->checkout_qty; $i++) { | ||
AccessoryCheckout::create([ | ||
|
||
$accessory_checkout = new AccessoryCheckout([ | ||
'accessory_id' => $accessory->id, | ||
'created_at' => Carbon::now(), | ||
'created_by' => auth()->id(), | ||
'assigned_to' => $target->id, | ||
'assigned_type' => $target::class, | ||
'note' => $request->input('note'), | ||
]); | ||
|
||
$accessory_checkout->created_by = auth()->id(); | ||
$accessory_checkout->save(); | ||
} | ||
|
||
// Set this value to be able to pass the qty through to the event | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.