Skip to content

Commit 5b657de

Browse files
authored
Update composer.json (#46)
* Update composer.json * Update .travis.yml * Update composer.json * Update ApiMakeCommand.php * Apply fixes from StyleCI (#47) * update for non id columns as id
1 parent 16be675 commit 5b657de

File tree

4 files changed

+7
-9
lines changed

4 files changed

+7
-9
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ php:
1414

1515
env:
1616
- LARAVEL_VERSION=6.*
17+
- LARAVEL_VERSION=7.*
1718

1819
before_install:
1920
- travis_retry composer self-update --stable -n

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
],
1717
"require": {
1818
"php": ">=7.2",
19-
"illuminate/support": "^6.0"
19+
"illuminate/support": "^6.0|^7.0"
2020
},
2121
"require-dev": {
22-
"orchestra/testbench": "^4.0",
22+
"orchestra/testbench": "^4.0|^5.0",
2323
"phpunit/phpunit": "^8.0"
2424
},
2525
"autoload": {

src/Generator/ApiMakeCommand.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,13 @@
33
namespace Phpsa\LaravelApiController\Generator;
44

55
use Illuminate\Console\Command;
6-
use Illuminate\Console\DetectsApplicationNamespace;
76
use Illuminate\Filesystem\Filesystem;
87
use Illuminate\Support\Str;
98
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
109
use Symfony\Component\Console\Input\InputArgument;
1110

1211
class ApiMakeCommand extends Command
1312
{
14-
use DetectsApplicationNamespace;
15-
1613
/**
1714
* The filesystem instance.
1815
*
@@ -113,7 +110,7 @@ protected function createOptionals()
113110
*/
114111
protected function prepareVariablesForStubs($name)
115112
{
116-
$this->stubVariables['app']['namespace'] = $this->getAppNamespace();
113+
$this->stubVariables['app']['namespace'] = $this->laravel->getNamespace();
117114
$baseDir = config('laravel-api-controller.models_base_dir');
118115
$this->modelsBaseNamespace = $baseDir ? trim($baseDir, '\\').'\\' : '';
119116
$this->setModelData($name)

src/Http/Controllers/Api/Controller.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public function handleStoreAction($request, array $extraParams = [])
168168

169169
DB::commit();
170170

171-
return $this->respondItemCreated($this->repository->getById($item->id));
171+
return $this->respondItemCreated($this->repository->getById($item->getKey()));
172172
} catch (\Illuminate\Database\QueryException $exception) {
173173
$message = config('app.debug') ? $exception->getMessage() : 'Failed to create Record';
174174

@@ -238,7 +238,7 @@ public function handleUpdateAction($id, $request, array $extraParams = [])
238238
return $this->errorNotFound('Record does not exist');
239239
}
240240

241-
$this->validate($request, $this->rulesForUpdate($item->id));
241+
$this->validate($request, $this->rulesForUpdate($item->getKey()));
242242

243243
$data = $this->qualifyUpdateQuery($data);
244244

@@ -262,7 +262,7 @@ public function handleUpdateAction($id, $request, array $extraParams = [])
262262

263263
DB::commit();
264264

265-
return $this->respondWithOne($this->repository->getById($item->id));
265+
return $this->respondWithOne($this->repository->getById($item->getKey()));
266266
} catch (\Illuminate\Database\QueryException $exception) {
267267
$message = config('app.debug') ? $exception->getMessage() : 'Failed to update Record';
268268

0 commit comments

Comments
 (0)