Skip to content

Commit 985c62d

Browse files
committed
Merge branch '53-Entity-generator_2.0' into 'master'
#53: Closes #53 See merge request components/laravel-entity-generator!79
2 parents 4d1596e + 137845d commit 985c62d

File tree

5 files changed

+11
-8
lines changed

5 files changed

+11
-8
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"laravel/framework": ">=5.4.0",
1515
"guzzlehttp/guzzle": "~6.0",
1616
"tymon/jwt-auth": "0.5.* || 1.0.*@beta",
17-
"ronasit/laravel-helpers": ">=1.3"
17+
"ronasit/laravel-helpers": "2.0.0-beta"
1818
},
1919
"require-dev": {
2020
"fzaninotto/faker": "~1.4",

src/Commands/MakeEntityCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ protected function checkConfigs()
184184
$newConfig = $this->outputNewConfig($packageConfigs, $projectConfigs);
185185

186186
if ($newConfig !== $projectConfigs) {
187-
$this->info('Config has been updated');
187+
$this->comment('Config has been updated');
188188
Config::set('entity-generator', $newConfig);
189189
file_put_contents(config_path('entity-generator.php'), "<?php\n\nreturn" . $this->customVarExport($newConfig) . ';');
190190
}
@@ -200,7 +200,7 @@ protected function outputNewConfig($packageConfigs, $projectConfigs)
200200
$differences = array_diff_key($newConfig, $flattenedProjectConfigs);
201201

202202
foreach ($differences as $differenceKey => $differenceValue) {
203-
$this->info("Key '{$differenceKey}' was missing in your config, we added it with the value '{$differenceValue}'");
203+
$this->comment("Key '{$differenceKey}' was missing in your config, we added it with the value '{$differenceValue}'");
204204
}
205205

206206
return array_undot($newConfig);
@@ -332,4 +332,4 @@ protected function validateOnlyApiOption()
332332
}
333333
}
334334
}
335-
}
335+
}

stubs/controller.blade.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ public function create(Create{{$entity}}Request $request, {{$entity}}Service $se
3535
public function get(Get{{$entity}}Request $request, {{$entity}}Service $service, $id)
3636
{
3737
$result = $service
38-
->withRelations($request->input('with', []))
38+
->with($request->input('with', []))
39+
->withCount($request->input('with_count', []))
3940
->find($id);
4041

4142
return response()->json($result);
@@ -67,4 +68,4 @@ public function delete(Delete{{$entity}}Request $request, {{$entity}}Service $se
6768
}
6869

6970
@endif
70-
}
71+
}

stubs/request.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
class {{$method}}{{$entity}}Request extends Request
1010
{
11-
public function rules()
11+
public function rules(): array
1212
{
1313
@if(!empty($parameters))
1414
return [

stubs/service.blade.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
namespace App\Services;
22

3+
use Illuminate\Support\Arr;
34
use RonasIT\Support\Services\EntityService;
45
use App\Repositories\{{$entity}}Repository;
56
{{--
@@ -25,14 +26,15 @@ public function __construct()
2526
public function search($filters)
2627
{
2728
return $this->repository
29+
->with(Arr::get($filters, 'with', []))
30+
->withCount(Arr::get($filters, 'with_count', []))
2831
->searchQuery($filters)
2932
@foreach($fields['simple_search'] as $field)
3033
->filterBy('{{$field}}')
3134
@endforeach
3235
@if(!empty($fields['search_by_query']))
3336
->filterByQuery(['{!! implode('\', \'', $fields['search_by_query']) !!}'])
3437
@endif
35-
->with()
3638
->getSearchResults();
3739
}
3840
}

0 commit comments

Comments
 (0)