Skip to content

Commit

Permalink
Merge pull request #63 from one2tek/2.x
Browse files Browse the repository at this point in the history
2.x
  • Loading branch information
gentritabazi authored Jan 18, 2021
2 parents 26df4e2 + 7e6fd42 commit 2ba6708
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/Console/ComponentMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ class ComponentMakeCommand extends Command
],
'Exceptions' => [
'NotFoundException'
],
'Requests' => [
'CreateRequest',
'UpdateRequest'
]
];

Expand Down
11 changes: 6 additions & 5 deletions src/Console/Stubs/controllers/controller.stub
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
namespace DummyNamespace;

use DummyPath\Services\DummyVariableService;
use Illuminate\Http\Request;
use Infrastructure\Abstracts\Controller;
use DummyPath\Requests\DummyVariableCreateRequest;
use DummyPath\Requests\DummyVariableUpdateRequest;

class DummyClass extends Controller
{
Expand Down Expand Up @@ -34,18 +35,18 @@ class DummyClass extends Controller
return $this->response($sendData);
}

public function create(Request $request)
public function create(DummyVariableCreateRequest $request)
{
$data = $request->all();
$data = $request->validated();

$sendData['dummyvariable'] = $this->dummyVariableService->create($data);

return $this->response($sendData, 201);
}

public function update($dummyVariableId, Request $request)
public function update($dummyVariableId, DummyVariableUpdateRequest $request)
{
$data = $request->all();
$data = $request->validated();

$sendData['dummyvariable'] = $this->dummyVariableService->update($dummyVariableId, $data);

Expand Down
16 changes: 16 additions & 0 deletions src/Console/Stubs/requests/createrequest.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace DummyNamespace;

use Infrastructure\Abstracts\ApiRequest;

class DummyClass extends ApiRequest
{
public function rules()
{
return [
'field1' => 'required',
'field2' => 'required'
];
}
}
16 changes: 16 additions & 0 deletions src/Console/Stubs/requests/updaterequest.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace DummyNamespace;

use Infrastructure\Abstracts\ApiRequest;

class DummyClass extends ApiRequest
{
public function rules()
{
return [
'field1' => 'nullable',
'field2' => 'nullable'
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
namespace one2tek\larapi\Providers;

use one2tek\larapi\Routes\ApiConsumerRouter;
use Illuminate\Support\ServiceProvider as BaseProvider;
use Illuminate\Support\ServiceProvider;
use one2tek\larapi\Console\ComponentMakeCommand;

class LaravelServiceProvider extends BaseProvider
class LarapiServiceProvider extends ServiceProvider
{
/**
* Register any application services.
Expand Down

0 comments on commit 2ba6708

Please sign in to comment.