Skip to content

Commit

Permalink
Remove AllowedNullableFilter
Browse files Browse the repository at this point in the history
  • Loading branch information
ericwang401 committed Dec 1, 2023
1 parent d61ea6d commit d5908d2
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 40 deletions.
6 changes: 3 additions & 3 deletions app/Http/Controllers/Admin/AddressPools/AddressController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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) {
Expand Down
49 changes: 28 additions & 21 deletions app/Http/Controllers/Admin/Nodes/AddressController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
16 changes: 0 additions & 16 deletions app/Models/Filters/AllowedNullableFilter.php

This file was deleted.

0 comments on commit d5908d2

Please sign in to comment.