Skip to content

Commit

Permalink
create skeleton for implementing Coterm
Browse files Browse the repository at this point in the history
  • Loading branch information
ericwang401 committed Nov 28, 2023
1 parent 4376991 commit 9d179b5
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 5 deletions.
13 changes: 9 additions & 4 deletions app/Http/Controllers/Admin/CotermController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

namespace Convoy\Http\Controllers\Admin;

use Convoy\Http\Requests\Admin\Coterms\StoreCotermRequest;
use Convoy\Http\Requests\Admin\Coterms\UpdateAttachedNodesRequest;
use Convoy\Http\Requests\Admin\Coterms\UpdateCotermRequest;
use Convoy\Models\Coterm;
use Illuminate\Http\Request;

class CotermController
Expand All @@ -11,20 +15,21 @@ public function index()

}

public function store(Request $request)
public function store(StoreCotermRequest $request)
{

}

public function show($id)
public function update(UpdateCotermRequest $request, Coterm $coterm)
{
}

public function update(Request $request, $id)
public function updateAttachedNodes(UpdateAttachedNodesRequest $request, Coterm $coterm)
{

}

public function destroy($id)
public function destroy(Coterm $coterm)
{
}
}
17 changes: 17 additions & 0 deletions app/Http/Requests/Admin/Coterms/StoreCotermRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Convoy\Http\Requests\Admin\Coterms;

use Convoy\Http\Requests\BaseApiRequest;
use Convoy\Models\Coterm;
use Illuminate\Support\Arr;

class StoreCotermRequest extends BaseApiRequest
{
public function rules(): array
{
$rules = Coterm::getRules();

return Arr::only($rules, ['name', 'is_tls_enabled', 'fqdn', 'port']);
}
}
16 changes: 16 additions & 0 deletions app/Http/Requests/Admin/Coterms/UpdateAttachedNodesRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Convoy\Http\Requests\Admin\Coterms;

use Convoy\Http\Requests\BaseApiRequest;

class UpdateAttachedNodesRequest extends BaseApiRequest
{
public function rules(): array
{
return [
'node_ids' => 'required|array',
'nodes_ids.*' => 'required|integer|exists:nodes,id',
];
}
}
18 changes: 18 additions & 0 deletions app/Http/Requests/Admin/Coterms/UpdateCotermRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Convoy\Http\Requests\Admin\Coterms;

use Convoy\Http\Requests\BaseApiRequest;
use Convoy\Models\Coterm;
use Illuminate\Support\Arr;

class UpdateCotermRequest extends BaseApiRequest
{
public function rules(): array
{
$coterm = $this->parameter('coterm', Coterm::class);
$rules = Coterm::getRulesForUpdate($coterm);

return Arr::only($rules, ['name', 'is_tls_enabled', 'fqdn', 'port']);
}
}
2 changes: 1 addition & 1 deletion app/Models/Coterm.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Convoy\Models;

use Convoy\Casts\NullableEncrypter;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;

Expand All @@ -28,6 +27,7 @@ class Coterm extends Model
];

public static $validationRules = [
'name' => 'required|string|max:191',
'is_tls_enabled' => 'required|boolean',
'fqdn' => 'required|string|max:191',
'port' => 'required|integer|min:1|max:65535',
Expand Down

0 comments on commit 9d179b5

Please sign in to comment.