|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Http\Controllers; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Http\Request; |
|
|
|
|
|
|
6
|
|
|
|
|
7
|
|
|
class PublicApiController extends Controller |
|
8
|
|
|
{ |
|
9
|
|
|
|
|
10
|
|
|
public function things(Request $request) |
|
11
|
|
|
{ |
|
12
|
|
|
$libraryId = $request->input('library'); |
|
13
|
|
|
|
|
14
|
|
|
$things = Thing::with('items'); |
|
15
|
|
|
if ($request->has('library')) { |
|
16
|
|
|
$things->whereHas(''); |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
|
|
20
|
|
|
$things = Thing::with('items', 'settings', 'items.loans') |
|
21
|
|
|
->orderBy('name') |
|
22
|
|
|
->get(); |
|
23
|
|
|
|
|
24
|
|
|
$things = $things->map(function ($thing) use ($libraryId) { |
|
25
|
|
|
$all = $thing->items->whereNotIn('barcode', [null]); |
|
26
|
|
|
$avail = $all->filter(function (Item $item) { |
|
27
|
|
|
return is_null($item->activeLoan); |
|
28
|
|
|
}); |
|
29
|
|
|
$mine = $all->where('library_id', $libraryId); |
|
30
|
|
|
$avail_mine = $avail->where('library_id', $libraryId); |
|
31
|
|
|
|
|
32
|
|
|
return [ |
|
33
|
|
|
'type' => 'thing', |
|
34
|
|
|
'id' => $thing->id, |
|
35
|
|
|
'name' => $thing->name, |
|
36
|
|
|
'library_settings' => $thing->library_settings, |
|
37
|
|
|
'properties' => $thing->properties, |
|
38
|
|
|
'loan_time' => $thing->loan_time, |
|
39
|
|
|
|
|
40
|
|
|
'items_total' => $all->count(), |
|
41
|
|
|
'items_mine' => $mine->count(), |
|
42
|
|
|
|
|
43
|
|
|
'avail_total' => $avail->count(), |
|
44
|
|
|
'avail_mine' => $avail_mine->count(), |
|
45
|
|
|
]; |
|
46
|
|
|
}); |
|
47
|
|
|
|
|
48
|
|
|
return response()->view('things.index', [ |
|
|
|
|
|
|
49
|
|
|
'things' => $things, |
|
50
|
|
|
]); |
|
51
|
|
|
} |
|
52
|
|
|
} |
|
53
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths