diff --git a/app/Http/Controllers/Admin/AddressPools/AddressController.php b/app/Http/Controllers/Admin/AddressPools/AddressController.php index b84ba1ce2db..c9289d2d134 100644 --- a/app/Http/Controllers/Admin/AddressPools/AddressController.php +++ b/app/Http/Controllers/Admin/AddressPools/AddressController.php @@ -10,7 +10,6 @@ use Convoy\Jobs\Server\SyncNetworkSettings; use Convoy\Models\Address; use Convoy\Models\AddressPool; -use Convoy\Models\Filters\AllowedNullableFilter; use Convoy\Models\Filters\FiltersAddress; use Convoy\Repositories\Eloquent\AddressRepository; use Convoy\Services\Servers\NetworkService; @@ -41,7 +40,7 @@ public function index(Request $request, AddressPool $addressPool) ), AllowedFilter::custom( '*', new FiltersAddress(), - ), AllowedNullableFilter::exact('server_id')], + ), AllowedFilter::exact('server_id')->nullable()], ) ->paginate(min($request->query('per_page', 50), 100))->appends( $request->query(), @@ -108,7 +107,8 @@ public function store(StoreAddressRequest $request, AddressPool $addressPool) } } - public function update(UpdateAddressRequest $request, AddressPool $addressPool, Address $address, + public function update( + UpdateAddressRequest $request, AddressPool $addressPool, Address $address, ) { $address = $this->connection->transaction(function () use ($request, $address) { diff --git a/app/Http/Controllers/Admin/Nodes/AddressController.php b/app/Http/Controllers/Admin/Nodes/AddressController.php index 87c582238c8..5b6866e187f 100644 --- a/app/Http/Controllers/Admin/Nodes/AddressController.php +++ b/app/Http/Controllers/Admin/Nodes/AddressController.php @@ -2,41 +2,47 @@ namespace Convoy\Http\Controllers\Admin\Nodes; -use Convoy\Models\Node; -use Convoy\Models\Address; -use Illuminate\Http\Request; -use Spatie\QueryBuilder\QueryBuilder; -use Spatie\QueryBuilder\AllowedFilter; +use Convoy\Exceptions\Repository\Proxmox\ProxmoxConnectionException; use Convoy\Http\Controllers\Controller; +use Convoy\Http\Requests\Admin\AddressPools\Addresses\UpdateAddressRequest; +use Convoy\Models\Address; use Convoy\Models\Filters\FiltersAddress; +use Convoy\Models\Node; use Convoy\Services\Servers\NetworkService; -use Illuminate\Database\ConnectionInterface; -use Convoy\Models\Filters\AllowedNullableFilter; use Convoy\Transformers\Admin\AddressTransformer; -use Convoy\Exceptions\Repository\Proxmox\ProxmoxConnectionException; -use Convoy\Http\Requests\Admin\AddressPools\Addresses\UpdateAddressRequest; +use Illuminate\Database\ConnectionInterface; +use Illuminate\Http\Request; +use Spatie\QueryBuilder\AllowedFilter; +use Spatie\QueryBuilder\QueryBuilder; use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException; class AddressController extends Controller { - public function __construct(private NetworkService $networkService, private ConnectionInterface $connection) + public function __construct( + private NetworkService $networkService, private ConnectionInterface $connection, + ) { } public function index(Request $request, Node $node) { $addresses = QueryBuilder::for($node->addresses()) - ->with('server') - ->defaultSort('-id') - ->allowedFilters( - ['address', AllowedFilter::exact('type'), AllowedFilter::custom( - '*', - new FiltersAddress, - ), AllowedNullableFilter::exact('server_id')], - ) - ->paginate(min($request->query('per_page', 50), 100))->appends($request->query()); + ->with('server') + ->defaultSort('-id') + ->allowedFilters( + ['address', AllowedFilter::exact( + 'type', + ), AllowedFilter::custom( + '*', + new FiltersAddress(), + ), AllowedFilter::exact('server_id')->nullable()], + ) + ->paginate(min($request->query('per_page', 50), 100))->appends( + $request->query(), + ); - return fractal($addresses, new AddressTransformer)->parseIncludes($request->include)->respond(); + return fractal($addresses, new AddressTransformer())->parseIncludes($request->include) + ->respond(); } public function update(UpdateAddressRequest $request, Node $node, Address $address) @@ -75,7 +81,8 @@ public function update(UpdateAddressRequest $request, Node $node, Address $addre return $address; }); - return fractal($address, new AddressTransformer)->parseIncludes($request->include)->respond(); + return fractal($address, new AddressTransformer())->parseIncludes($request->include) + ->respond(); } public function destroy(Node $node, Address $address) diff --git a/app/Models/Filters/AllowedNullableFilter.php b/app/Models/Filters/AllowedNullableFilter.php deleted file mode 100644 index b97bccbe88b..00000000000 --- a/app/Models/Filters/AllowedNullableFilter.php +++ /dev/null @@ -1,16 +0,0 @@ -resolveValueForFiltering($value); - - ($this->filterClass)($query->getEloquentBuilder(), $valueToFilter, $this->internalName); - } -}