|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Providers; |
|
4
|
|
|
|
|
5
|
|
|
use App\Item; |
|
6
|
|
|
use App\Loan; |
|
7
|
|
|
use App\Thing; |
|
8
|
|
|
use App\User; |
|
9
|
|
|
use Illuminate\Support\Facades\Route; |
|
|
|
|
|
|
10
|
|
|
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; |
|
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
class RouteServiceProvider extends ServiceProvider |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* This namespace is applied to your controller routes. |
|
16
|
|
|
* |
|
17
|
|
|
* In addition, it is set as the URL generator's root namespace. |
|
18
|
|
|
* |
|
19
|
|
|
* @var string |
|
20
|
|
|
*/ |
|
21
|
|
|
protected $namespace = 'App\Http\Controllers'; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Define your route model bindings, pattern filters, etc. |
|
25
|
|
|
* |
|
26
|
|
|
* @return void |
|
27
|
|
|
*/ |
|
28
|
|
|
public function boot() |
|
29
|
|
|
{ |
|
30
|
|
|
Route::pattern('user', '([0-9]+|_new)'); |
|
31
|
|
|
Route::pattern('item', '([0-9]+|_new)'); |
|
32
|
|
|
Route::pattern('thing', '([0-9]+|_new)'); |
|
33
|
|
|
|
|
34
|
|
|
Route::pattern('library', '[0-9]+'); |
|
35
|
|
|
Route::pattern('user1', '[0-9]+'); |
|
36
|
|
|
Route::pattern('user2', '[0-9]+'); |
|
37
|
|
|
Route::pattern('loan', '[0-9]+'); |
|
38
|
|
|
Route::pattern('reminder', '[0-9]+'); |
|
39
|
|
|
Route::pattern('notification', '[0-9]+'); |
|
40
|
|
|
Route::pattern('ip', '[0-9]+'); |
|
41
|
|
|
|
|
42
|
|
|
parent::boot(); |
|
43
|
|
|
|
|
44
|
|
|
Route::bind('thing', function ($value) { |
|
45
|
|
|
return $value == '_new' |
|
46
|
|
|
? new Thing(['properties' => []]) |
|
47
|
|
|
: Thing::withTrashed() |
|
48
|
|
|
->with('items.loans') |
|
49
|
|
|
->with('items.allLoans') |
|
50
|
|
|
->find($value) ?? abort(404); |
|
|
|
|
|
|
51
|
|
|
}); |
|
52
|
|
|
|
|
53
|
|
|
Route::bind('item', function ($value) { |
|
54
|
|
|
return $value == '_new' |
|
55
|
|
|
? new Item([ 'library_id' => \Auth::user()->id ]) |
|
|
|
|
|
|
56
|
|
|
: Item::withTrashed()->find($value) ?? abort(404); |
|
|
|
|
|
|
57
|
|
|
}); |
|
58
|
|
|
|
|
59
|
|
|
Route::bind('user', function ($value) { |
|
60
|
|
|
return $value == '_new' |
|
61
|
|
|
? new User() |
|
62
|
|
|
: User::find($value) ?? abort(404); |
|
|
|
|
|
|
63
|
|
|
}); |
|
64
|
|
|
|
|
65
|
|
|
Route::bind('loan', function ($value) { |
|
66
|
|
|
return Loan::withTrashed()->find($value) ?? abort(404); |
|
|
|
|
|
|
67
|
|
|
}); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Define the routes for the application. |
|
72
|
|
|
* |
|
73
|
|
|
* @return void |
|
74
|
|
|
*/ |
|
75
|
|
|
public function map() |
|
76
|
|
|
{ |
|
77
|
|
|
$this->mapApiRoutes(); |
|
78
|
|
|
|
|
79
|
|
|
$this->mapWebRoutes(); |
|
80
|
|
|
|
|
81
|
|
|
$this->mapWebhooksRoutes(); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* Define the "web" routes for the application. |
|
86
|
|
|
* |
|
87
|
|
|
* These routes all receive session state, CSRF protection, etc. |
|
88
|
|
|
* |
|
89
|
|
|
* @return void |
|
90
|
|
|
*/ |
|
91
|
|
|
protected function mapWebRoutes() |
|
92
|
|
|
{ |
|
93
|
|
|
Route::middleware('web') |
|
94
|
|
|
->namespace($this->namespace) |
|
95
|
|
|
->group(base_path('routes/web.php')); |
|
|
|
|
|
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* Define the "api" routes for the application. |
|
100
|
|
|
* |
|
101
|
|
|
* These routes are typically stateless. |
|
102
|
|
|
* |
|
103
|
|
|
* @return void |
|
104
|
|
|
*/ |
|
105
|
|
|
protected function mapApiRoutes() |
|
106
|
|
|
{ |
|
107
|
|
|
Route::prefix('api') |
|
108
|
|
|
->middleware('api') |
|
109
|
|
|
->namespace($this->namespace) |
|
110
|
|
|
->group(base_path('routes/api.php')); |
|
|
|
|
|
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
/** |
|
114
|
|
|
* Define the "webhooks" routes for the application. |
|
115
|
|
|
* |
|
116
|
|
|
* These routes are typically stateless. |
|
117
|
|
|
* |
|
118
|
|
|
* @return void |
|
119
|
|
|
*/ |
|
120
|
|
|
protected function mapWebhooksRoutes() |
|
121
|
|
|
{ |
|
122
|
|
|
Route::prefix('webhooks') |
|
123
|
|
|
->middleware('webhooks') |
|
124
|
|
|
->namespace($this->namespace) |
|
125
|
|
|
->group(base_path('routes/webhooks.php')); |
|
|
|
|
|
|
126
|
|
|
} |
|
127
|
|
|
} |
|
128
|
|
|
|
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