diff --git a/app/Http/Controllers/Resources/VariableController.php b/app/Http/Controllers/Resources/VariableController.php new file mode 100644 index 000000000..c1dfaf182 --- /dev/null +++ b/app/Http/Controllers/Resources/VariableController.php @@ -0,0 +1,56 @@ +repository = $repository; + } + + /** + * Store a newly created variable in storage. + * + * @param StoreVariableRequest $request + * @return Response + */ + public function store(StoreVariableRequest $request) + { + return $this->repository->create($request->only( + 'name', + 'value', + 'project_id' + )); + } + + /** + * Update the specified variable in storage. + * + * @param int $variable_id + * @param StoreVariableRequest $request + * @return Response + */ + public function update($variable_id, StoreVariableRequest $request) + { + return $this->repository->updateById($request->only( + 'name', + 'value', + 'project_id' + ), $variable_id); + } +} diff --git a/app/Http/Requests/StoreVariableRequest.php b/app/Http/Requests/StoreVariableRequest.php new file mode 100644 index 000000000..701b59218 --- /dev/null +++ b/app/Http/Requests/StoreVariableRequest.php @@ -0,0 +1,25 @@ + 'required|max:255', + 'value' => 'required', + 'project_id' => 'required|integer|exists:projects,id', + ]; + } +} diff --git a/app/Http/routes.php b/app/Http/routes.php index fe24e0727..4212d3879 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -57,6 +57,7 @@ ]; Route::resource('servers', 'ServerController', $actions); + Route::resource('variables', 'VariableController', $actions); Route::resource('commands', 'CommandController', $actions); Route::resource('heartbeats', 'HeartbeatController', $actions); Route::resource('notifications', 'NotificationController', $actions); diff --git a/app/Providers/RepositoryServiceProvider.php b/app/Providers/RepositoryServiceProvider.php index 98872faf6..87c9631e5 100644 --- a/app/Providers/RepositoryServiceProvider.php +++ b/app/Providers/RepositoryServiceProvider.php @@ -40,6 +40,7 @@ public function register() $this->bindInterface('SharedFile'); $this->bindInterface('Template'); $this->bindInterface('User'); + $this->bindInterface('Variable'); } /** diff --git a/app/Repositories/Contracts/VariableRepositoryInterface.php b/app/Repositories/Contracts/VariableRepositoryInterface.php new file mode 100644 index 000000000..0ea3bd2eb --- /dev/null +++ b/app/Repositories/Contracts/VariableRepositoryInterface.php @@ -0,0 +1,11 @@ +model = $model; + } +} diff --git a/resources/assets/js/variables.js b/resources/assets/js/variables.js index 558096a9e..440c2e9a8 100644 --- a/resources/assets/js/variables.js +++ b/resources/assets/js/variables.js @@ -43,9 +43,9 @@ var app = app || {}; } variable.save({ - name: $('#variable_name').val(), - value: $('#variable_value').val(), - name: $('#variable_name').val() + name: $('#variable_name').val(), + value: $('#variable_value').val(), + project_id: $('input[name="project_id"]').val(), }, { wait: true, success: function(model, response, options) {