From 9d179b5cd45d0c834a5b5341c72e00640fcac36f Mon Sep 17 00:00:00 2001 From: Eric Wang <37554696+ericwang401@users.noreply.github.com> Date: Mon, 27 Nov 2023 21:06:54 -0600 Subject: [PATCH] create skeleton for implementing Coterm --- .../Controllers/Admin/CotermController.php | 13 +++++++++---- .../Admin/Coterms/StoreCotermRequest.php | 17 +++++++++++++++++ .../Coterms/UpdateAttachedNodesRequest.php | 16 ++++++++++++++++ .../Admin/Coterms/UpdateCotermRequest.php | 18 ++++++++++++++++++ app/Models/Coterm.php | 2 +- 5 files changed, 61 insertions(+), 5 deletions(-) create mode 100644 app/Http/Requests/Admin/Coterms/StoreCotermRequest.php create mode 100644 app/Http/Requests/Admin/Coterms/UpdateAttachedNodesRequest.php create mode 100644 app/Http/Requests/Admin/Coterms/UpdateCotermRequest.php diff --git a/app/Http/Controllers/Admin/CotermController.php b/app/Http/Controllers/Admin/CotermController.php index 6c066bc073a..ab9c17676b7 100644 --- a/app/Http/Controllers/Admin/CotermController.php +++ b/app/Http/Controllers/Admin/CotermController.php @@ -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 @@ -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) { } } diff --git a/app/Http/Requests/Admin/Coterms/StoreCotermRequest.php b/app/Http/Requests/Admin/Coterms/StoreCotermRequest.php new file mode 100644 index 00000000000..972efdb13ec --- /dev/null +++ b/app/Http/Requests/Admin/Coterms/StoreCotermRequest.php @@ -0,0 +1,17 @@ + 'required|array', + 'nodes_ids.*' => 'required|integer|exists:nodes,id', + ]; + } +} diff --git a/app/Http/Requests/Admin/Coterms/UpdateCotermRequest.php b/app/Http/Requests/Admin/Coterms/UpdateCotermRequest.php new file mode 100644 index 00000000000..7725f6a38c2 --- /dev/null +++ b/app/Http/Requests/Admin/Coterms/UpdateCotermRequest.php @@ -0,0 +1,18 @@ +parameter('coterm', Coterm::class); + $rules = Coterm::getRulesForUpdate($coterm); + + return Arr::only($rules, ['name', 'is_tls_enabled', 'fqdn', 'port']); + } +} diff --git a/app/Models/Coterm.php b/app/Models/Coterm.php index 60d04cf6ab6..11e93f0a216 100644 --- a/app/Models/Coterm.php +++ b/app/Models/Coterm.php @@ -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; @@ -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',