Skip to content

Commit 78c1ae1

Browse files
authored
Refactor/vic laravel template (#19)
* feat(repository): add updated_at to default filters * refactor(resource): generate base request * feat(seed): add environment verification * refactor(request): change store prepareForValidation from replace to merge * refactor(request): change update prepareForValidation from replace to merge * 1.2.9: app version
1 parent 33256b1 commit 78c1ae1

File tree

6 files changed

+10
-9
lines changed

6 files changed

+10
-9
lines changed

app/templates/laravel/app/Http/Requests/__name__StoreRequest.php.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class <%= namePascal %>StoreRequest extends CoreRequest
1313
*/
1414
protected function prepareForValidation()
1515
{
16-
return $this->replace([
16+
return $this->merge([
1717
//
1818
]);
1919
}

app/templates/laravel/app/Http/Requests/__name__UpdateRequest.php.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class <%= namePascal %>UpdateRequest extends CoreRequest
1313
*/
1414
protected function prepareForValidation()
1515
{
16-
return $this->replace([
16+
return $this->merge([
1717
//
1818
]);
1919
}

app/templates/laravel/app/Http/Resources/__name__Resource.php.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ class <%= namePascal %>Resource extends JsonResource
1414
*/
1515
public function toArray($request)
1616
{
17-
return [
18-
//
19-
];
17+
return parent::toArray($request);
2018
}
2119
}

app/templates/laravel/app/Repositories/__name__Repository.php.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class <%= namePascal %>Repository extends CoreRepository
2323
* Allowed model columns to use in sort
2424
* @var array
2525
*/
26-
protected $allow_order = array('created_at');
26+
protected $allow_order = array('created_at','updated_at');
2727

2828
/**
2929
* Allowed model columns to use in query search
@@ -35,7 +35,7 @@ class <%= namePascal %>Repository extends CoreRepository
3535
* Allowed model columns to use in filter by date
3636
* @var array
3737
*/
38-
protected $allow_between_dates = array('created_at');
38+
protected $allow_between_dates = array('created_at','updated_at');
3939

4040
/**
4141
* Allowed model columns to use in filter by value

app/templates/laravel/database/seeders/__name__Seeder.php.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ namespace Database\Seeders;
44

55
use App\Models\<%= namePascal %>;
66
use Illuminate\Database\Seeder;
7+
use Illuminate\Support\Facades\App;
78

89
class <%= namePascal %>Seeder extends Seeder
910
{
@@ -14,6 +15,8 @@ class <%= namePascal %>Seeder extends Seeder
1415
*/
1516
public function run()
1617
{
17-
<%= namePascal %>::factory(1)->create();
18+
if (App::environment('local')) {
19+
<%= namePascal %>::factory(1)->create();
20+
}
1821
}
1922
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "generator-secjs",
3-
"version": "1.2.8",
3+
"version": "1.2.9",
44
"description": "🧬 Generator for any NodeJS Project or Framework",
55
"main": "app/index.js",
66
"scripts": {

0 commit comments

Comments
 (0)