-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6e78e4f
commit f8d8c44
Showing
7 changed files
with
121 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
namespace REBELinBLUE\Deployer\Http\Controllers\Resources; | ||
|
||
use Illuminate\Support\Facades\Input; | ||
use REBELinBLUE\Deployer\Http\Requests; | ||
use REBELinBLUE\Deployer\Http\Requests\StoreVariableRequest; | ||
use REBELinBLUE\Deployer\Repositories\Contracts\VariableRepositoryInterface; | ||
|
||
/** | ||
* Variable management controller. | ||
*/ | ||
class VariableController extends ResourceController | ||
{ | ||
/** | ||
* Class constructor. | ||
* | ||
* @param VariableRepositoryInterface $repository | ||
* @return void | ||
*/ | ||
public function __construct(VariableRepositoryInterface $repository) | ||
{ | ||
$this->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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace REBELinBLUE\Deployer\Http\Requests; | ||
|
||
use REBELinBLUE\Deployer\Http\Requests\Request; | ||
|
||
/** | ||
* Request for validating variables. | ||
*/ | ||
class StoreVariableRequest extends Request | ||
{ | ||
/** | ||
* Get the validation rules that apply to the request. | ||
* | ||
* @return array | ||
*/ | ||
public function rules() | ||
{ | ||
return [ | ||
'name' => 'required|max:255', | ||
'value' => 'required', | ||
'project_id' => 'required|integer|exists:projects,id', | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
app/Repositories/Contracts/VariableRepositoryInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace REBELinBLUE\Deployer\Repositories\Contracts; | ||
|
||
interface VariableRepositoryInterface | ||
{ | ||
public function getAll(); | ||
public function create(array $fields); | ||
public function updateById(array $fields, $model_id); | ||
public function deleteById($model_id); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace REBELinBLUE\Deployer\Repositories; | ||
|
||
use REBELinBLUE\Deployer\Variable; | ||
use REBELinBLUE\Deployer\Repositories\Contracts\VariableRepositoryInterface; | ||
use REBELinBLUE\Deployer\Repositories\EloquentRepository; | ||
|
||
/** | ||
* The variable repository. | ||
*/ | ||
class EloquentVariableRepository extends EloquentRepository implements VariableRepositoryInterface | ||
{ | ||
/** | ||
* Class constructor. | ||
* | ||
* @param Variable $model | ||
* @return EloquentVariableRepository | ||
*/ | ||
public function __construct(Variable $model) | ||
{ | ||
$this->model = $model; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters