Skip to content

Commit e6fb16d

Browse files
authored
Merge pull request #9 from SecJS/feat/vic-add-laravel-template v1.2.0
Feat/vic add laravel template
2 parents eb9d6eb + 2d5aea3 commit e6fb16d

15 files changed

Lines changed: 374 additions & 8 deletions

README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,6 @@ Then generate your files:
3232
yo secjs Foo --path=./Bar
3333
```
3434

35-
or
36-
37-
```bash
38-
yo generator-secjs Customer --path=./Customer
39-
```
40-
4135
## Next Steps
4236

4337
- [x] Generate code by Framework/Language

app/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class SecGenerator extends Generator {
4141
name: 'framework',
4242
message: 'Select your framework:',
4343
choices: [
44+
{ name: 'Laravel', value: 'laravel' },
4445
{ name: 'NestJS TypeORM', value: 'nestjsTypeOrm' },
4546
{ name: 'NestJS Mongoose', value: 'nestjsMongoose' },
4647
{ name: 'NestJS PrismaORM', value: 'nestjsPrismaOrm' },
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
use App\Http\Resources\<%= namePascal %>Resource;
6+
use App\Repositories\<%= namePascal %>Repository;
7+
use App\Services\<%= namePascal %>Service;
8+
use Txsoura\Core\Http\Controllers\Traits\CRUDMethodsController;
9+
use Txsoura\Core\Http\Controllers\Traits\SoftDeleteMethodsController;
10+
11+
class <%= namePascal %>Controller extends Controller
12+
{
13+
use CRUDMethodsController, SoftDeleteMethodsController;
14+
15+
/**
16+
* @var <%= namePascal %>Repository
17+
*/
18+
protected $repository;
19+
20+
/**
21+
* @var <%= namePascal %>Resource
22+
*/
23+
protected $resource = <%= namePascal %>Resource::class;
24+
25+
/**
26+
* @var <%= namePascal %>Service
27+
*/
28+
protected $service;
29+
30+
/**
31+
* <%= namePascal %>Controller constructor.
32+
*/
33+
public function __construct(<%= namePascal %>Service $service, <%= namePascal %>Repository $repository)
34+
{
35+
$this->service = $service;
36+
$this->repository = $repository;
37+
}
38+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace App\Http\Requests;
4+
5+
use Txsoura\Core\Http\Requests\CoreRequest;
6+
7+
class <%= namePascal %>StoreRequest extends CoreRequest
8+
{
9+
/**
10+
* Prepare the data for validation.
11+
*
12+
* @return void
13+
*/
14+
protected function prepareForValidation()
15+
{
16+
return $this->replace([
17+
//
18+
]);
19+
}
20+
21+
/**
22+
* Get the validation rules that apply to the request.
23+
*
24+
* @return array
25+
*/
26+
public function rules()
27+
{
28+
return [
29+
//
30+
];
31+
}
32+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace App\Http\Requests;
4+
5+
use Txsoura\Core\Http\Requests\CoreRequest;
6+
7+
class <%= namePascal %>UpdateRequest extends CoreRequest
8+
{
9+
/**
10+
* Prepare the data for validation.
11+
*
12+
* @return void
13+
*/
14+
protected function prepareForValidation()
15+
{
16+
return $this->replace([
17+
//
18+
]);
19+
}
20+
21+
/**
22+
* Get the validation rules that apply to the request.
23+
*
24+
* @return array
25+
*/
26+
public function rules()
27+
{
28+
return [
29+
//
30+
];
31+
}
32+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace App\Http\Resources;
4+
5+
use Illuminate\Http\Resources\Json\JsonResource;
6+
7+
class <%= namePascal %>Resource extends JsonResource
8+
{
9+
/**
10+
* Transform the resource into an array.
11+
*
12+
* @param \Illuminate\Http\Request $request
13+
* @return array
14+
*/
15+
public function toArray($request)
16+
{
17+
return [
18+
//
19+
];
20+
}
21+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace App\Models;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
use Illuminate\Database\Eloquent\SoftDeletes;
7+
use Illuminate\Database\Eloquent\Factories\HasFactory;
8+
9+
class <%= namePascal %> extends Model
10+
{
11+
use SoftDeletes, HasFactory;
12+
13+
/**
14+
* The attributes that are mass assignable.
15+
*
16+
* @var array
17+
*/
18+
protected $fillable = [];
19+
20+
protected $dates = [];
21+
22+
/**
23+
* The attributes that should be cast.
24+
*
25+
* @var array
26+
*/
27+
protected $casts = [];
28+
29+
/**
30+
* The model's default values for attributes.
31+
*
32+
* @var array
33+
*/
34+
protected $attributes = [];
35+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
namespace App\Repositories;
4+
5+
use App\Models\<%= namePascal %>;
6+
use Txsoura\Core\Repositories\CoreRepository;
7+
8+
class <%= namePascal %>Repository extends CoreRepository
9+
{
10+
/**
11+
* Allow model relations to use in include
12+
* @var array
13+
*/
14+
protected $possibleRelationships = [];
15+
16+
/**
17+
* Allowed model columns to use in conditional query
18+
* @var array
19+
*/
20+
protected $allow_where = array();
21+
22+
/**
23+
* Allowed model columns to use in sort
24+
* @var array
25+
*/
26+
protected $allow_order = array('created_at');
27+
28+
/**
29+
* Allowed model columns to use in query search
30+
* @var array
31+
*/
32+
protected $allow_like = array();
33+
34+
/**
35+
* Allowed model columns to use in filter by date
36+
* @var array
37+
*/
38+
protected $allow_between_dates = array('created_at');
39+
40+
/**
41+
* Allowed model columns to use in filter by value
42+
* @var array
43+
*/
44+
protected $allow_between_values = array();
45+
46+
protected function model(): string
47+
{
48+
return <%= namePascal %>::class;
49+
}
50+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
namespace App\Services;
4+
5+
use App\Http\Requests\<%= namePascal %>StoreRequest;
6+
use App\Http\Requests\<%= namePascal %>UpdateRequest;
7+
use App\Models\<%= namePascal %>;
8+
use App\Repositories\<%= namePascal %>Repository;
9+
use Txsoura\Core\Services\CoreService;
10+
use Txsoura\Core\Services\Traits\CRUDMethodsService;
11+
use Txsoura\Core\Services\Traits\SoftDeleteMethodsService;
12+
13+
class <%= namePascal %>Service extends CoreService
14+
{
15+
use CRUDMethodsService, SoftDeleteMethodsService;
16+
17+
protected $storeRequest = <%= namePascal %>StoreRequest::class;
18+
protected $updateRequest = <%= namePascal %>UpdateRequest::class;
19+
20+
/**
21+
* @var <%= namePascal %>Repository
22+
*/
23+
protected $repository;
24+
25+
/**
26+
* <%= namePascal %>Service constructor.
27+
* @param <%= namePascal %>Repository $repository
28+
*/
29+
public function __construct(<%= namePascal %>Repository $repository)
30+
{
31+
$this->repository = $repository;
32+
}
33+
34+
/**
35+
* Model class for crud.
36+
*
37+
* @return string
38+
*/
39+
protected function model(): string
40+
{
41+
return <%= namePascal %>::class;
42+
}
43+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace Database\Factories;
4+
5+
use App\Models\<%= namePascal %>;
6+
use Illuminate\Database\Eloquent\Factories\Factory;
7+
8+
class <%= namePascal %>Factory extends Factory
9+
{
10+
/**
11+
* The name of the factory's corresponding model.
12+
*
13+
* @var string
14+
*/
15+
protected $model = <%= namePascal %>::class;
16+
17+
/**
18+
* Define the model's default state.
19+
*
20+
* @return array
21+
*/
22+
public function definition()
23+
{
24+
return [
25+
//
26+
];
27+
}
28+
}

0 commit comments

Comments
 (0)