Commit 98ceb7205ba411403f005fe90c70f729499d276e
1 parent
69c0fada
Exists in
2.9
and in
8 other branches
Configura o Prettus Repository e cria repositories relacionados ao menu
Showing
22 changed files
with
901 additions
and
24 deletions
Show diff stats
... | ... | @@ -0,0 +1,40 @@ |
1 | +<?php | |
2 | + | |
3 | +namespace App\Entities; | |
4 | + | |
5 | +use Illuminate\Database\Eloquent\Model; | |
6 | +use Prettus\Repository\Contracts\Transformable; | |
7 | +use Prettus\Repository\Traits\TransformableTrait; | |
8 | + | |
9 | +/** | |
10 | + * Class Funcionario. | |
11 | + * | |
12 | + * @package namespace App\Entities; | |
13 | + */ | |
14 | +class Employee extends Model implements Transformable | |
15 | +{ | |
16 | + use TransformableTrait; | |
17 | + | |
18 | + /** | |
19 | + * @var string | |
20 | + */ | |
21 | + protected $table = 'portal.funcionario'; | |
22 | + | |
23 | + /** | |
24 | + * @var string | |
25 | + */ | |
26 | + protected $primaryKey = 'ref_cod_pessoa_fj'; | |
27 | + | |
28 | + /** | |
29 | + * @var bool | |
30 | + */ | |
31 | + public $timestamps = false; | |
32 | + | |
33 | + /** | |
34 | + * The attributes that are mass assignable. | |
35 | + * | |
36 | + * @var array | |
37 | + */ | |
38 | + protected $fillable = []; | |
39 | + | |
40 | +} | ... | ... |
... | ... | @@ -0,0 +1,40 @@ |
1 | +<?php | |
2 | + | |
3 | +namespace App\Entities; | |
4 | + | |
5 | +use Illuminate\Database\Eloquent\Model; | |
6 | +use Prettus\Repository\Contracts\Transformable; | |
7 | +use Prettus\Repository\Traits\TransformableTrait; | |
8 | + | |
9 | +/** | |
10 | + * Class Fisica. | |
11 | + * | |
12 | + * @package namespace App\Entities; | |
13 | + */ | |
14 | +class Individual extends Model implements Transformable | |
15 | +{ | |
16 | + use TransformableTrait; | |
17 | + | |
18 | + /** | |
19 | + * @var string | |
20 | + */ | |
21 | + protected $table = 'cadastro.fisica'; | |
22 | + | |
23 | + /** | |
24 | + * @var string | |
25 | + */ | |
26 | + protected $primaryKey = 'idpes'; | |
27 | + | |
28 | + /** | |
29 | + * @var bool | |
30 | + */ | |
31 | + public $timestamps = false; | |
32 | + | |
33 | + /** | |
34 | + * The attributes that are mass assignable. | |
35 | + * | |
36 | + * @var array | |
37 | + */ | |
38 | + protected $fillable = []; | |
39 | + | |
40 | +} | ... | ... |
... | ... | @@ -0,0 +1,44 @@ |
1 | +<?php | |
2 | + | |
3 | +namespace App\Entities; | |
4 | + | |
5 | +use Illuminate\Database\Eloquent\Model; | |
6 | +use Prettus\Repository\Contracts\Transformable; | |
7 | +use Prettus\Repository\Traits\TransformableTrait; | |
8 | + | |
9 | +/** | |
10 | + * Class Menu. | |
11 | + * | |
12 | + * @package namespace App\Entities; | |
13 | + */ | |
14 | +class Menu extends Model implements Transformable | |
15 | +{ | |
16 | + use TransformableTrait; | |
17 | + | |
18 | + /** | |
19 | + * @var string | |
20 | + */ | |
21 | + protected $table = 'portal.menu_menu'; | |
22 | + | |
23 | + /** | |
24 | + * @var string | |
25 | + */ | |
26 | + protected $primaryKey = 'cod_menu_menu'; | |
27 | + | |
28 | + /** | |
29 | + * @var bool | |
30 | + */ | |
31 | + public $timestamps = false; | |
32 | + | |
33 | + /** | |
34 | + * The attributes that are mass assignable. | |
35 | + * | |
36 | + * @var array | |
37 | + */ | |
38 | + protected $fillable = []; | |
39 | + | |
40 | + public function submenus() | |
41 | + { | |
42 | + return $this->hasMany(Submenu::class, 'ref_cod_menu_menu', 'cod_menu_menu'); | |
43 | + } | |
44 | +} | ... | ... |
... | ... | @@ -0,0 +1,40 @@ |
1 | +<?php | |
2 | + | |
3 | +namespace App\Entities; | |
4 | + | |
5 | +use Illuminate\Database\Eloquent\Model; | |
6 | +use Prettus\Repository\Contracts\Transformable; | |
7 | +use Prettus\Repository\Traits\TransformableTrait; | |
8 | + | |
9 | +/** | |
10 | + * Class Pessoa. | |
11 | + * | |
12 | + * @package namespace App\Entities; | |
13 | + */ | |
14 | +class Person extends Model implements Transformable | |
15 | +{ | |
16 | + use TransformableTrait; | |
17 | + | |
18 | + /** | |
19 | + * @var string | |
20 | + */ | |
21 | + protected $table = 'cadastro.pessoa'; | |
22 | + | |
23 | + /** | |
24 | + * @var string | |
25 | + */ | |
26 | + protected $primaryKey = 'idpes'; | |
27 | + | |
28 | + /** | |
29 | + * @var bool | |
30 | + */ | |
31 | + public $timestamps = false; | |
32 | + | |
33 | + /** | |
34 | + * The attributes that are mass assignable. | |
35 | + * | |
36 | + * @var array | |
37 | + */ | |
38 | + protected $fillable = []; | |
39 | + | |
40 | +} | ... | ... |
... | ... | @@ -0,0 +1,56 @@ |
1 | +<?php | |
2 | + | |
3 | +namespace App\Entities; | |
4 | + | |
5 | +use Illuminate\Database\Eloquent\Model; | |
6 | +use Prettus\Repository\Contracts\Transformable; | |
7 | +use Prettus\Repository\Traits\TransformableTrait; | |
8 | + | |
9 | +/** | |
10 | + * Class Submenu. | |
11 | + * | |
12 | + * @package namespace App\Entities; | |
13 | + */ | |
14 | +class Submenu extends Model implements Transformable | |
15 | +{ | |
16 | + const SUPER_USER_MENU_ID = 0; | |
17 | + | |
18 | + use TransformableTrait; | |
19 | + | |
20 | + /** | |
21 | + * @var string | |
22 | + */ | |
23 | + protected $table = 'portal.menu_submenu'; | |
24 | + | |
25 | + /** | |
26 | + * @var string | |
27 | + */ | |
28 | + protected $primaryKey = 'cod_menu_submenu'; | |
29 | + | |
30 | + /** | |
31 | + * @var bool | |
32 | + */ | |
33 | + public $timestamps = false; | |
34 | + | |
35 | + /** | |
36 | + * The attributes that are mass assignable. | |
37 | + * | |
38 | + * @var array | |
39 | + */ | |
40 | + protected $fillable = []; | |
41 | + | |
42 | + public function menu() | |
43 | + { | |
44 | + return $this->belongsTo(Menu::class, 'ref_cod_menu_menu', 'cod_menu_menu'); | |
45 | + } | |
46 | + | |
47 | + public function typeUsers() | |
48 | + { | |
49 | + return $this->belongsToMany( | |
50 | + UserType::class, | |
51 | + 'pmieducar.menu_tipo_usuario', | |
52 | + 'ref_cod_menu_submenu', | |
53 | + 'ref_cod_tipo_usuario' | |
54 | + ); | |
55 | + } | |
56 | +} | ... | ... |
... | ... | @@ -0,0 +1,44 @@ |
1 | +<?php | |
2 | + | |
3 | +namespace App\Entities; | |
4 | + | |
5 | +use Illuminate\Database\Eloquent\Model; | |
6 | +use Prettus\Repository\Contracts\Transformable; | |
7 | +use Prettus\Repository\Traits\TransformableTrait; | |
8 | + | |
9 | +/** | |
10 | + * Class User. | |
11 | + * | |
12 | + * @package namespace App\Entities; | |
13 | + */ | |
14 | +class User extends Model implements Transformable | |
15 | +{ | |
16 | + use TransformableTrait; | |
17 | + | |
18 | + /** | |
19 | + * @var string | |
20 | + */ | |
21 | + protected $table = 'pmieducar.usuario'; | |
22 | + | |
23 | + /** | |
24 | + * @var string | |
25 | + */ | |
26 | + protected $primaryKey = 'cod_usuario'; | |
27 | + | |
28 | + /** | |
29 | + * @var bool | |
30 | + */ | |
31 | + public $timestamps = false; | |
32 | + | |
33 | + /** | |
34 | + * The attributes that are mass assignable. | |
35 | + * | |
36 | + * @var array | |
37 | + */ | |
38 | + protected $fillable = []; | |
39 | + | |
40 | + public function type() | |
41 | + { | |
42 | + return $this->belongsTo(UserType::class, 'ref_cod_tipo_usuario', 'cod_tipo_usuario'); | |
43 | + } | |
44 | +} | ... | ... |
... | ... | @@ -0,0 +1,45 @@ |
1 | +<?php | |
2 | + | |
3 | +namespace App\Entities; | |
4 | + | |
5 | +use Illuminate\Database\Eloquent\Model; | |
6 | +use Prettus\Repository\Contracts\Transformable; | |
7 | +use Prettus\Repository\Traits\TransformableTrait; | |
8 | + | |
9 | +/** | |
10 | + * Class UserType. | |
11 | + * | |
12 | + * @package namespace App\Entities; | |
13 | + */ | |
14 | +class UserType extends Model implements Transformable | |
15 | +{ | |
16 | + use TransformableTrait; | |
17 | + | |
18 | + /** | |
19 | + * @var string | |
20 | + */ | |
21 | + protected $table = 'pmieducar.tipo_usuario'; | |
22 | + | |
23 | + /** | |
24 | + * @var string | |
25 | + */ | |
26 | + protected $primaryKey = 'cod_tipo_usuario'; | |
27 | + | |
28 | + /** | |
29 | + * @var bool | |
30 | + */ | |
31 | + public $timestamps = false; | |
32 | + | |
33 | + /** | |
34 | + * The attributes that are mass assignable. | |
35 | + * | |
36 | + * @var array | |
37 | + */ | |
38 | + protected $fillable = []; | |
39 | + | |
40 | + public function users() | |
41 | + { | |
42 | + return $this->hasMany(User::class, 'ref_cod_tipo_usuario', 'cod_tipo_usuario'); | |
43 | + } | |
44 | + | |
45 | +} | ... | ... |
app/Providers/AppServiceProvider.php
... | ... | @@ -0,0 +1,32 @@ |
1 | +<?php | |
2 | + | |
3 | +namespace App\Providers; | |
4 | + | |
5 | +use Illuminate\Support\ServiceProvider; | |
6 | + | |
7 | +class RepositoryServiceProvider extends ServiceProvider | |
8 | +{ | |
9 | + /** | |
10 | + * Bootstrap services. | |
11 | + * | |
12 | + * @return void | |
13 | + */ | |
14 | + public function boot() | |
15 | + { | |
16 | + // | |
17 | + } | |
18 | + | |
19 | + /** | |
20 | + * Register services. | |
21 | + * | |
22 | + * @return void | |
23 | + */ | |
24 | + public function register() | |
25 | + { | |
26 | + $this->app->bind(\iEducar\Support\Repositories\MenuRepository::class, \App\Repositories\MenuRepositoryEloquent::class); | |
27 | + $this->app->bind(\iEducar\Support\Repositories\SubmenuRepository::class, \App\Repositories\SubmenuRepositoryEloquent::class); | |
28 | + $this->app->bind(\iEducar\Support\Repositories\UserRepository::class, \App\Repositories\UserRepositoryEloquent::class); | |
29 | + $this->app->bind(\iEducar\Support\Repositories\UserTypeRepository::class, \App\Repositories\UserTypeRepositoryEloquent::class); | |
30 | + //:end-bindings: | |
31 | + } | |
32 | +} | ... | ... |
... | ... | @@ -0,0 +1,36 @@ |
1 | +<?php | |
2 | + | |
3 | +namespace App\Repositories; | |
4 | + | |
5 | +use App\Entities\User; | |
6 | +use iEducar\Support\Repositories\MenuRepository; | |
7 | +use Prettus\Repository\Eloquent\BaseRepository; | |
8 | +use Prettus\Repository\Criteria\RequestCriteria; | |
9 | +use App\Entities\Menu; | |
10 | +use App\Validators\MenuValidator; | |
11 | + | |
12 | +/** | |
13 | + * Class MenuRepositoryEloquent. | |
14 | + * | |
15 | + * @package namespace App\Repositories; | |
16 | + */ | |
17 | +class MenuRepositoryEloquent extends BaseRepository implements MenuRepository | |
18 | +{ | |
19 | + /** | |
20 | + * Specify Model class name | |
21 | + * | |
22 | + * @return string | |
23 | + */ | |
24 | + public function model() | |
25 | + { | |
26 | + return Menu::class; | |
27 | + } | |
28 | + | |
29 | + /** | |
30 | + * Boot up the repository, pushing criteria | |
31 | + */ | |
32 | + public function boot() | |
33 | + { | |
34 | + $this->pushCriteria(app(RequestCriteria::class)); | |
35 | + } | |
36 | +} | ... | ... |
... | ... | @@ -0,0 +1,38 @@ |
1 | +<?php | |
2 | + | |
3 | +namespace App\Repositories; | |
4 | + | |
5 | +use iEducar\Support\Repositories\SubmenuRepository; | |
6 | +use Prettus\Repository\Eloquent\BaseRepository; | |
7 | +use Prettus\Repository\Criteria\RequestCriteria; | |
8 | +use App\Entities\Submenu; | |
9 | +use App\Validators\SubmenuValidator; | |
10 | + | |
11 | +/** | |
12 | + * Class SubmenuRepositoryEloquent. | |
13 | + * | |
14 | + * @package namespace App\Repositories; | |
15 | + */ | |
16 | +class SubmenuRepositoryEloquent extends BaseRepository implements SubmenuRepository | |
17 | +{ | |
18 | + /** | |
19 | + * Specify Model class name | |
20 | + * | |
21 | + * @return string | |
22 | + */ | |
23 | + public function model() | |
24 | + { | |
25 | + return Submenu::class; | |
26 | + } | |
27 | + | |
28 | + | |
29 | + | |
30 | + /** | |
31 | + * Boot up the repository, pushing criteria | |
32 | + */ | |
33 | + public function boot() | |
34 | + { | |
35 | + $this->pushCriteria(app(RequestCriteria::class)); | |
36 | + } | |
37 | + | |
38 | +} | ... | ... |
... | ... | @@ -0,0 +1,38 @@ |
1 | +<?php | |
2 | + | |
3 | +namespace App\Repositories; | |
4 | + | |
5 | +use iEducar\Support\Repositories\UserRepository; | |
6 | +use Prettus\Repository\Eloquent\BaseRepository; | |
7 | +use Prettus\Repository\Criteria\RequestCriteria; | |
8 | +use App\Entities\User; | |
9 | +use App\Validators\UserValidator; | |
10 | + | |
11 | +/** | |
12 | + * Class UserRepositoryEloquent. | |
13 | + * | |
14 | + * @package namespace App\Repositories; | |
15 | + */ | |
16 | +class UserRepositoryEloquent extends BaseRepository implements UserRepository | |
17 | +{ | |
18 | + /** | |
19 | + * Specify Model class name | |
20 | + * | |
21 | + * @return string | |
22 | + */ | |
23 | + public function model() | |
24 | + { | |
25 | + return User::class; | |
26 | + } | |
27 | + | |
28 | + | |
29 | + | |
30 | + /** | |
31 | + * Boot up the repository, pushing criteria | |
32 | + */ | |
33 | + public function boot() | |
34 | + { | |
35 | + $this->pushCriteria(app(RequestCriteria::class)); | |
36 | + } | |
37 | + | |
38 | +} | ... | ... |
... | ... | @@ -0,0 +1,36 @@ |
1 | +<?php | |
2 | + | |
3 | +namespace App\Repositories; | |
4 | + | |
5 | +use iEducar\Support\Repositories\UserTypeRepository; | |
6 | +use Prettus\Repository\Eloquent\BaseRepository; | |
7 | +use Prettus\Repository\Criteria\RequestCriteria; | |
8 | +use App\Entities\UserType; | |
9 | +use App\Validators\UserTypeValidator; | |
10 | + | |
11 | +/** | |
12 | + * Class UserTypeRepositoryEloquent. | |
13 | + * | |
14 | + * @package namespace App\Repositories; | |
15 | + */ | |
16 | +class UserTypeRepositoryEloquent extends BaseRepository implements UserTypeRepository | |
17 | +{ | |
18 | + /** | |
19 | + * Specify Model class name | |
20 | + * | |
21 | + * @return string | |
22 | + */ | |
23 | + public function model() | |
24 | + { | |
25 | + return UserType::class; | |
26 | + } | |
27 | + | |
28 | + /** | |
29 | + * Boot up the repository, pushing criteria | |
30 | + */ | |
31 | + public function boot() | |
32 | + { | |
33 | + $this->pushCriteria(app(RequestCriteria::class)); | |
34 | + } | |
35 | + | |
36 | +} | ... | ... |
composer.json
... | ... | @@ -17,6 +17,7 @@ |
17 | 17 | "honeybadger-io/honeybadger-php": "^1.2", |
18 | 18 | "laravel/framework": "5.6.*", |
19 | 19 | "laravel/tinker": "^1.0", |
20 | + "prettus/l5-repository": "^2.6", | |
20 | 21 | "robmorgan/phinx": "^0.10.6", |
21 | 22 | "swiftmailer/swiftmailer": "^6.1", |
22 | 23 | "tooleks/laravel-asset-version": "^1.0" | ... | ... |
composer.lock
... | ... | @@ -4,7 +4,7 @@ |
4 | 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", |
5 | 5 | "This file is @generated automatically" |
6 | 6 | ], |
7 | - "content-hash": "5b167c229ff04d8269825e0163309151", | |
7 | + "content-hash": "8b3f1dda9d0e383845dcdb75620482e4", | |
8 | 8 | "packages": [ |
9 | 9 | { |
10 | 10 | "name": "cakephp/cache", |
... | ... | @@ -1646,6 +1646,109 @@ |
1646 | 1646 | "time": "2018-07-02T15:55:56+00:00" |
1647 | 1647 | }, |
1648 | 1648 | { |
1649 | + "name": "prettus/l5-repository", | |
1650 | + "version": "2.6.32", | |
1651 | + "source": { | |
1652 | + "type": "git", | |
1653 | + "url": "https://github.com/andersao/l5-repository.git", | |
1654 | + "reference": "f6ebfffee80a38e1d2dcf479e70b1a9ead397c24" | |
1655 | + }, | |
1656 | + "dist": { | |
1657 | + "type": "zip", | |
1658 | + "url": "https://api.github.com/repos/andersao/l5-repository/zipball/f6ebfffee80a38e1d2dcf479e70b1a9ead397c24", | |
1659 | + "reference": "f6ebfffee80a38e1d2dcf479e70b1a9ead397c24", | |
1660 | + "shasum": "" | |
1661 | + }, | |
1662 | + "require": { | |
1663 | + "illuminate/config": "~5.0", | |
1664 | + "illuminate/console": "~5.0", | |
1665 | + "illuminate/database": "~5.0", | |
1666 | + "illuminate/filesystem": "~5.0", | |
1667 | + "illuminate/http": "~5.0", | |
1668 | + "illuminate/pagination": "~5.0", | |
1669 | + "illuminate/support": "~5.0", | |
1670 | + "prettus/laravel-validation": "1.1.*" | |
1671 | + }, | |
1672 | + "suggest": { | |
1673 | + "league/fractal": "Required to use the Fractal Presenter (0.12.*).", | |
1674 | + "prettus/laravel-validation": "Required to provide easy validation with the repository (1.1.*)", | |
1675 | + "robclancy/presenter": "Required to use the Presenter Model (1.3.*)" | |
1676 | + }, | |
1677 | + "type": "library", | |
1678 | + "extra": { | |
1679 | + "laravel": { | |
1680 | + "providers": [ | |
1681 | + "Prettus\\Repository\\Providers\\RepositoryServiceProvider" | |
1682 | + ] | |
1683 | + } | |
1684 | + }, | |
1685 | + "autoload": { | |
1686 | + "psr-4": { | |
1687 | + "Prettus\\Repository\\": "src/Prettus/Repository/" | |
1688 | + } | |
1689 | + }, | |
1690 | + "notification-url": "https://packagist.org/downloads/", | |
1691 | + "license": [ | |
1692 | + "MIT" | |
1693 | + ], | |
1694 | + "authors": [ | |
1695 | + { | |
1696 | + "name": "Anderson Andrade", | |
1697 | + "email": "contato@andersonandra.de", | |
1698 | + "role": "Developer" | |
1699 | + } | |
1700 | + ], | |
1701 | + "description": "Laravel 5 - Repositories to the database layer", | |
1702 | + "keywords": [ | |
1703 | + "cache", | |
1704 | + "eloquent", | |
1705 | + "laravel", | |
1706 | + "model", | |
1707 | + "repository" | |
1708 | + ], | |
1709 | + "time": "2018-01-27T15:53:20+00:00" | |
1710 | + }, | |
1711 | + { | |
1712 | + "name": "prettus/laravel-validation", | |
1713 | + "version": "1.1.5", | |
1714 | + "source": { | |
1715 | + "type": "git", | |
1716 | + "url": "https://github.com/andersao/laravel-validator.git", | |
1717 | + "reference": "d9eb401fb3518a890b117e83bd25a4109fcdb704" | |
1718 | + }, | |
1719 | + "dist": { | |
1720 | + "type": "zip", | |
1721 | + "url": "https://api.github.com/repos/andersao/laravel-validator/zipball/d9eb401fb3518a890b117e83bd25a4109fcdb704", | |
1722 | + "reference": "d9eb401fb3518a890b117e83bd25a4109fcdb704", | |
1723 | + "shasum": "" | |
1724 | + }, | |
1725 | + "require": { | |
1726 | + "illuminate/support": "~5.4", | |
1727 | + "illuminate/validation": "~5.4", | |
1728 | + "php": ">=5.4.0" | |
1729 | + }, | |
1730 | + "type": "library", | |
1731 | + "autoload": { | |
1732 | + "psr-4": { | |
1733 | + "Prettus\\Validator\\": "src/Prettus/Validator/" | |
1734 | + } | |
1735 | + }, | |
1736 | + "notification-url": "https://packagist.org/downloads/", | |
1737 | + "authors": [ | |
1738 | + { | |
1739 | + "name": "Anderson Andrade", | |
1740 | + "email": "contato@andersonandra.de" | |
1741 | + } | |
1742 | + ], | |
1743 | + "description": "Laravel Validation Service", | |
1744 | + "keywords": [ | |
1745 | + "laravel", | |
1746 | + "service", | |
1747 | + "validation" | |
1748 | + ], | |
1749 | + "time": "2017-08-28T23:28:32+00:00" | |
1750 | + }, | |
1751 | + { | |
1649 | 1752 | "name": "psr/container", |
1650 | 1753 | "version": "1.0.0", |
1651 | 1754 | "source": { | ... | ... |
config/app.php
... | ... | @@ -0,0 +1,244 @@ |
1 | +<?php | |
2 | +/* | |
3 | +|-------------------------------------------------------------------------- | |
4 | +| Prettus Repository Config | |
5 | +|-------------------------------------------------------------------------- | |
6 | +| | |
7 | +| | |
8 | +*/ | |
9 | +return [ | |
10 | + | |
11 | + /* | |
12 | + |-------------------------------------------------------------------------- | |
13 | + | Repository Pagination Limit Default | |
14 | + |-------------------------------------------------------------------------- | |
15 | + | | |
16 | + */ | |
17 | + 'pagination' => [ | |
18 | + 'limit' => 15 | |
19 | + ], | |
20 | + | |
21 | + /* | |
22 | + |-------------------------------------------------------------------------- | |
23 | + | Fractal Presenter Config | |
24 | + |-------------------------------------------------------------------------- | |
25 | + | | |
26 | + | |
27 | + Available serializers: | |
28 | + ArraySerializer | |
29 | + DataArraySerializer | |
30 | + JsonApiSerializer | |
31 | + | |
32 | + */ | |
33 | + 'fractal' => [ | |
34 | + 'params' => [ | |
35 | + 'include' => 'include' | |
36 | + ], | |
37 | + 'serializer' => League\Fractal\Serializer\DataArraySerializer::class | |
38 | + ], | |
39 | + | |
40 | + /* | |
41 | + |-------------------------------------------------------------------------- | |
42 | + | Cache Config | |
43 | + |-------------------------------------------------------------------------- | |
44 | + | | |
45 | + */ | |
46 | + 'cache' => [ | |
47 | + /* | |
48 | + |-------------------------------------------------------------------------- | |
49 | + | Cache Status | |
50 | + |-------------------------------------------------------------------------- | |
51 | + | | |
52 | + | Enable or disable cache | |
53 | + | | |
54 | + */ | |
55 | + 'enabled' => false, | |
56 | + | |
57 | + /* | |
58 | + |-------------------------------------------------------------------------- | |
59 | + | Cache Minutes | |
60 | + |-------------------------------------------------------------------------- | |
61 | + | | |
62 | + | Time of expiration cache | |
63 | + | | |
64 | + */ | |
65 | + 'minutes' => 30, | |
66 | + | |
67 | + /* | |
68 | + |-------------------------------------------------------------------------- | |
69 | + | Cache Repository | |
70 | + |-------------------------------------------------------------------------- | |
71 | + | | |
72 | + | Instance of Illuminate\Contracts\Cache\Repository | |
73 | + | | |
74 | + */ | |
75 | + 'repository' => 'cache', | |
76 | + | |
77 | + /* | |
78 | + |-------------------------------------------------------------------------- | |
79 | + | Cache Clean Listener | |
80 | + |-------------------------------------------------------------------------- | |
81 | + | | |
82 | + | | |
83 | + | | |
84 | + */ | |
85 | + 'clean' => [ | |
86 | + | |
87 | + /* | |
88 | + |-------------------------------------------------------------------------- | |
89 | + | Enable clear cache on repository changes | |
90 | + |-------------------------------------------------------------------------- | |
91 | + | | |
92 | + */ | |
93 | + 'enabled' => true, | |
94 | + | |
95 | + /* | |
96 | + |-------------------------------------------------------------------------- | |
97 | + | Actions in Repository | |
98 | + |-------------------------------------------------------------------------- | |
99 | + | | |
100 | + | create : Clear Cache on create Entry in repository | |
101 | + | update : Clear Cache on update Entry in repository | |
102 | + | delete : Clear Cache on delete Entry in repository | |
103 | + | | |
104 | + */ | |
105 | + 'on' => [ | |
106 | + 'create' => true, | |
107 | + 'update' => true, | |
108 | + 'delete' => true, | |
109 | + ] | |
110 | + ], | |
111 | + | |
112 | + 'params' => [ | |
113 | + /* | |
114 | + |-------------------------------------------------------------------------- | |
115 | + | Skip Cache Params | |
116 | + |-------------------------------------------------------------------------- | |
117 | + | | |
118 | + | | |
119 | + | Ex: http://prettus.local/?search=lorem&skipCache=true | |
120 | + | | |
121 | + */ | |
122 | + 'skipCache' => 'skipCache' | |
123 | + ], | |
124 | + | |
125 | + /* | |
126 | + |-------------------------------------------------------------------------- | |
127 | + | Methods Allowed | |
128 | + |-------------------------------------------------------------------------- | |
129 | + | | |
130 | + | methods cacheable : all, paginate, find, findByField, findWhere, getByCriteria | |
131 | + | | |
132 | + | Ex: | |
133 | + | | |
134 | + | 'only' =>['all','paginate'], | |
135 | + | | |
136 | + | or | |
137 | + | | |
138 | + | 'except' =>['find'], | |
139 | + */ | |
140 | + 'allowed' => [ | |
141 | + 'only' => null, | |
142 | + 'except' => null | |
143 | + ] | |
144 | + ], | |
145 | + | |
146 | + /* | |
147 | + |-------------------------------------------------------------------------- | |
148 | + | Criteria Config | |
149 | + |-------------------------------------------------------------------------- | |
150 | + | | |
151 | + | Settings of request parameters names that will be used by Criteria | |
152 | + | | |
153 | + */ | |
154 | + 'criteria' => [ | |
155 | + /* | |
156 | + |-------------------------------------------------------------------------- | |
157 | + | Accepted Conditions | |
158 | + |-------------------------------------------------------------------------- | |
159 | + | | |
160 | + | Conditions accepted in consultations where the Criteria | |
161 | + | | |
162 | + | Ex: | |
163 | + | | |
164 | + | 'acceptedConditions'=>['=','like'] | |
165 | + | | |
166 | + | $query->where('foo','=','bar') | |
167 | + | $query->where('foo','like','bar') | |
168 | + | | |
169 | + */ | |
170 | + 'acceptedConditions' => [ | |
171 | + '=', | |
172 | + 'like' | |
173 | + ], | |
174 | + /* | |
175 | + |-------------------------------------------------------------------------- | |
176 | + | Request Params | |
177 | + |-------------------------------------------------------------------------- | |
178 | + | | |
179 | + | Request parameters that will be used to filter the query in the repository | |
180 | + | | |
181 | + | Params : | |
182 | + | | |
183 | + | - search : Searched value | |
184 | + | Ex: http://prettus.local/?search=lorem | |
185 | + | | |
186 | + | - searchFields : Fields in which research should be carried out | |
187 | + | Ex: | |
188 | + | http://prettus.local/?search=lorem&searchFields=name;email | |
189 | + | http://prettus.local/?search=lorem&searchFields=name:like;email | |
190 | + | http://prettus.local/?search=lorem&searchFields=name:like | |
191 | + | | |
192 | + | - filter : Fields that must be returned to the response object | |
193 | + | Ex: | |
194 | + | http://prettus.local/?search=lorem&filter=id,name | |
195 | + | | |
196 | + | - orderBy : Order By | |
197 | + | Ex: | |
198 | + | http://prettus.local/?search=lorem&orderBy=id | |
199 | + | | |
200 | + | - sortedBy : Sort | |
201 | + | Ex: | |
202 | + | http://prettus.local/?search=lorem&orderBy=id&sortedBy=asc | |
203 | + | http://prettus.local/?search=lorem&orderBy=id&sortedBy=desc | |
204 | + | | |
205 | + | - searchJoin: Specifies the search method (AND / OR), by default the | |
206 | + | application searches each parameter with OR | |
207 | + | EX: | |
208 | + | http://prettus.local/?search=lorem&searchJoin=and | |
209 | + | http://prettus.local/?search=lorem&searchJoin=or | |
210 | + | | |
211 | + */ | |
212 | + 'params' => [ | |
213 | + 'search' => 'search', | |
214 | + 'searchFields' => 'searchFields', | |
215 | + 'filter' => 'filter', | |
216 | + 'orderBy' => 'orderBy', | |
217 | + 'sortedBy' => 'sortedBy', | |
218 | + 'with' => 'with', | |
219 | + 'searchJoin' => 'searchJoin' | |
220 | + ] | |
221 | + ], | |
222 | + /* | |
223 | + |-------------------------------------------------------------------------- | |
224 | + | Generator Config | |
225 | + |-------------------------------------------------------------------------- | |
226 | + | | |
227 | + */ | |
228 | + 'generator' => [ | |
229 | + 'basePath' => app()->path(), | |
230 | + 'rootNamespace' => 'App\\', | |
231 | + 'stubsOverridePath' => app()->path(), | |
232 | + 'paths' => [ | |
233 | + 'models' => 'Entities', | |
234 | + 'repositories' => 'Repositories', | |
235 | + 'interfaces' => 'Repositories', | |
236 | + 'transformers' => 'Transformers', | |
237 | + 'presenters' => 'Presenters', | |
238 | + 'validators' => 'Validators', | |
239 | + 'controllers' => 'Http/Controllers', | |
240 | + 'provider' => 'RepositoryServiceProvider', | |
241 | + 'criteria' => 'Criteria' | |
242 | + ] | |
243 | + ] | |
244 | +]; | ... | ... |
database/factories/UserFactory.php
... | ... | @@ -1,23 +0,0 @@ |
1 | -<?php | |
2 | - | |
3 | -use Faker\Generator as Faker; | |
4 | - | |
5 | -/* | |
6 | -|-------------------------------------------------------------------------- | |
7 | -| Model Factories | |
8 | -|-------------------------------------------------------------------------- | |
9 | -| | |
10 | -| This directory should contain each of the model factory definitions for | |
11 | -| your application. Factories provide a convenient way to generate new | |
12 | -| model instances for testing / seeding your application's database. | |
13 | -| | |
14 | -*/ | |
15 | - | |
16 | -$factory->define(App\User::class, function (Faker $faker) { | |
17 | - return [ | |
18 | - 'name' => $faker->name, | |
19 | - 'email' => $faker->unique()->safeEmail, | |
20 | - 'password' => '$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret | |
21 | - 'remember_token' => str_random(10), | |
22 | - ]; | |
23 | -}); |
... | ... | @@ -0,0 +1,16 @@ |
1 | +<?php | |
2 | + | |
3 | +namespace iEducar\Support\Repositories; | |
4 | + | |
5 | +use App\Entities\User; | |
6 | +use Prettus\Repository\Contracts\RepositoryInterface; | |
7 | + | |
8 | +/** | |
9 | + * Interface MenuRepository. | |
10 | + * | |
11 | + * @package namespace App\Repositories; | |
12 | + */ | |
13 | +interface MenuRepository extends RepositoryInterface | |
14 | +{ | |
15 | + | |
16 | +} | ... | ... |
... | ... | @@ -0,0 +1,15 @@ |
1 | +<?php | |
2 | + | |
3 | +namespace iEducar\Support\Repositories; | |
4 | + | |
5 | +use Prettus\Repository\Contracts\RepositoryInterface; | |
6 | + | |
7 | +/** | |
8 | + * Interface SubmenuRepository. | |
9 | + * | |
10 | + * @package namespace App\Repositories; | |
11 | + */ | |
12 | +interface SubmenuRepository extends RepositoryInterface | |
13 | +{ | |
14 | + // | |
15 | +} | ... | ... |
... | ... | @@ -0,0 +1,15 @@ |
1 | +<?php | |
2 | + | |
3 | +namespace iEducar\Support\Repositories; | |
4 | + | |
5 | +use Prettus\Repository\Contracts\RepositoryInterface; | |
6 | + | |
7 | +/** | |
8 | + * Interface UserRepository. | |
9 | + * | |
10 | + * @package namespace App\Repositories; | |
11 | + */ | |
12 | +interface UserRepository extends RepositoryInterface | |
13 | +{ | |
14 | + // | |
15 | +} | ... | ... |
... | ... | @@ -0,0 +1,15 @@ |
1 | +<?php | |
2 | + | |
3 | +namespace iEducar\Support\Repositories; | |
4 | + | |
5 | +use Prettus\Repository\Contracts\RepositoryInterface; | |
6 | + | |
7 | +/** | |
8 | + * Interface UserTypeRepository. | |
9 | + * | |
10 | + * @package namespace App\Repositories; | |
11 | + */ | |
12 | +interface UserTypeRepository extends RepositoryInterface | |
13 | +{ | |
14 | + // | |
15 | +} | ... | ... |