update inbox list
This commit is contained in:
38
vendor/prettus/l5-repository/.editorconfig
vendored
Normal file
38
vendor/prettus/l5-repository/.editorconfig
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
# This file is for unifying the coding style for different editors and IDEs
|
||||
# editorconfig.org
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
end_of_line = lf
|
||||
|
||||
[**.less]
|
||||
indent_style = tab
|
||||
indent_size = 2
|
||||
|
||||
[**.{css,scss}]
|
||||
indent_style = tab
|
||||
indent_size = 2
|
||||
|
||||
[**.php]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
[**.html]
|
||||
indent_style = tab
|
||||
indent_size = 2
|
||||
|
||||
[**.js]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[**.yml]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
insert_final_newline = false
|
||||
|
||||
[**.md]
|
||||
indent_size = 4
|
||||
3
vendor/prettus/l5-repository/.gitignore
vendored
Normal file
3
vendor/prettus/l5-repository/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
.idea/
|
||||
composer.phar
|
||||
vendor/
|
||||
46
vendor/prettus/l5-repository/CODE_OF_CONDUCT.md
vendored
Normal file
46
vendor/prettus/l5-repository/CODE_OF_CONDUCT.md
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at contato@andersonandra.de. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
|
||||
|
||||
[homepage]: http://contributor-covenant.org
|
||||
[version]: http://contributor-covenant.org/version/1/4/
|
||||
18
vendor/prettus/l5-repository/CONTRIBUTING.md
vendored
Normal file
18
vendor/prettus/l5-repository/CONTRIBUTING.md
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
# Contributing
|
||||
|
||||
Contributions are **welcome** and will be fully **credited**.
|
||||
|
||||
|
||||
## Pull Requests
|
||||
|
||||
- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)**.
|
||||
|
||||
- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
|
||||
|
||||
- **Create feature branches** - Don't ask us to pull from your master branch.
|
||||
|
||||
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
|
||||
|
||||
- **Pull requests go against develop branch** - So we can test it before merging it onto master.
|
||||
|
||||
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.
|
||||
19
vendor/prettus/l5-repository/LICENSE.md
vendored
Normal file
19
vendor/prettus/l5-repository/LICENSE.md
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
# The MIT License (MIT)
|
||||
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
> of this software and associated documentation files (the "Software"), to deal
|
||||
> in the Software without restriction, including without limitation the rights
|
||||
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
> copies of the Software, and to permit persons to whom the Software is
|
||||
> furnished to do so, subject to the following conditions:
|
||||
>
|
||||
> The above copyright notice and this permission notice shall be included in
|
||||
> all copies or substantial portions of the Software.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
> THE SOFTWARE.
|
||||
1226
vendor/prettus/l5-repository/README.md
vendored
Normal file
1226
vendor/prettus/l5-repository/README.md
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
vendor/prettus/l5-repository/_config.yml
vendored
Normal file
1
vendor/prettus/l5-repository/_config.yml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
theme: jekyll-theme-cayman
|
||||
54
vendor/prettus/l5-repository/composer.json
vendored
Normal file
54
vendor/prettus/l5-repository/composer.json
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
{
|
||||
"name": "prettus/l5-repository",
|
||||
"description": "Laravel 5 - Repositories to the database layer",
|
||||
"keywords": ["laravel", "repository", "eloquent", "model", "cache"],
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Anderson Andrade",
|
||||
"homepage": "http://andersonandra.de",
|
||||
"email": "contato@andersonandra.de",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"homepage": "http://andersao.github.io/l5-repository",
|
||||
"support": {
|
||||
"email": "contato@andersonandra.de",
|
||||
"issues":"https://github.com/andersao/l5-repository/issues",
|
||||
"wiki":"https://github.com/andersao/l5-repository",
|
||||
"source":"https://github.com/andersao/l5-repository",
|
||||
"docs": "http://andersao.github.io/l5-repository"
|
||||
},
|
||||
"require": {
|
||||
"illuminate/http": "~5.0|~6.0|~7.0",
|
||||
"illuminate/config": "~5.0|~6.0|~7.0",
|
||||
"illuminate/support": "~5.0|~6.0|~7.0",
|
||||
"illuminate/database": "~5.0|~6.0|~7.0",
|
||||
"illuminate/pagination": "~5.0|~6.0|~7.0",
|
||||
"illuminate/console": "~5.0|~6.0|~7.0",
|
||||
"illuminate/filesystem": "~5.0|~6.0|~7.0",
|
||||
"prettus/laravel-validation": "~1.1|~1.2",
|
||||
"illuminate/validation": "~5.0|~6.0|~7.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Prettus\\Repository\\": "src/Prettus/Repository/"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"preferred-install": "dist"
|
||||
},
|
||||
"suggest": {
|
||||
"league/fractal": "Required to use the Fractal Presenter (0.12.*).",
|
||||
"robclancy/presenter": "Required to use the Presenter Model (1.3.*)",
|
||||
"prettus/laravel-validation": "Required to provide easy validation with the repository (1.1.*)"
|
||||
},
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Prettus\\Repository\\Providers\\RepositoryServiceProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
"minimum-stability": "stable"
|
||||
}
|
||||
1280
vendor/prettus/l5-repository/composer.lock
generated
vendored
Normal file
1280
vendor/prettus/l5-repository/composer.lock
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
41
vendor/prettus/l5-repository/migration-to-2.0.md
vendored
Normal file
41
vendor/prettus/l5-repository/migration-to-2.0.md
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
# Laravel 5 Repositories
|
||||
|
||||
[](https://packagist.org/packages/prettus/l5-repository)
|
||||
|
||||
## Migrate from version 1.0 to 2.0
|
||||
|
||||
### Registering the model's repository
|
||||
|
||||
*Versão 1.0*
|
||||
|
||||
```php
|
||||
use Prettus\Repository\Eloquent\Repository;
|
||||
|
||||
class PostRepository extends Repository {
|
||||
|
||||
public function __construct(Post $model)
|
||||
{
|
||||
parent::__construct($model);
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
*Versão 2.0*
|
||||
|
||||
```php
|
||||
use Prettus\Repository\Eloquent\BaseRepository;
|
||||
|
||||
class PostRepository extends BaseRepository {
|
||||
|
||||
/**
|
||||
* Specify Model class name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function model()
|
||||
{
|
||||
return "App\\Post";
|
||||
}
|
||||
}
|
||||
```
|
||||
32
vendor/prettus/l5-repository/migration-to-2.1.md
vendored
Normal file
32
vendor/prettus/l5-repository/migration-to-2.1.md
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
# Laravel 5 Repositories
|
||||
|
||||
[](https://packagist.org/packages/prettus/l5-repository)
|
||||
|
||||
Some changes between version 2.0 and 2.1
|
||||
|
||||
## Migrate from version 2.0 to 2.1
|
||||
|
||||
### Lumen Support
|
||||
|
||||
To use this package with Lumen , register the following service provider
|
||||
|
||||
```php
|
||||
$app->register(Prettus\Repository\Providers\LumenRepositoryServiceProvider::class);
|
||||
```
|
||||
|
||||
### Composer requirements
|
||||
|
||||
In version 2.0 some dependencies that could sometimes not be used in your project were always being downloaded regardless of whether they are used. In version 2.1 this package are as suggestions that will only be required if you want some features
|
||||
|
||||
|
||||
#### [Validators](https://github.com/prettus/l5-repository#validators)
|
||||
|
||||
If you want to use validations directly to your repository, as is disbelieved in Section [Validators](https://github.com/prettus/l5-repository#validators) , you need to use the library `prettus/laravel-validator`.
|
||||
|
||||
`composer require prettus/laravel-validator`
|
||||
|
||||
#### [Presenters](https://github.com/prettus/l5-repository#presenters)
|
||||
|
||||
If you want to use presenters in your repository, you need to use the library [`league/fractal`](http://fractal.thephpleague.com/).
|
||||
|
||||
`composer require league/fractal`
|
||||
18
vendor/prettus/l5-repository/phpunit.xml
vendored
Normal file
18
vendor/prettus/l5-repository/phpunit.xml
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
bootstrap="vendor/autoload.php"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
syntaxCheck="false"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="Prettus Repository Test Suite">
|
||||
<directory suffix=".php">./tests/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
||||
55
vendor/prettus/l5-repository/src/Prettus/Repository/Contracts/CacheableInterface.php
vendored
Normal file
55
vendor/prettus/l5-repository/src/Prettus/Repository/Contracts/CacheableInterface.php
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
namespace Prettus\Repository\Contracts;
|
||||
|
||||
use Illuminate\Contracts\Cache\Repository as CacheRepository;
|
||||
|
||||
/**
|
||||
* Interface CacheableInterface
|
||||
* @package Prettus\Repository\Contracts
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
interface CacheableInterface
|
||||
{
|
||||
/**
|
||||
* Set Cache Repository
|
||||
*
|
||||
* @param CacheRepository $repository
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCacheRepository(CacheRepository $repository);
|
||||
|
||||
/**
|
||||
* Return instance of Cache Repository
|
||||
*
|
||||
* @return CacheRepository
|
||||
*/
|
||||
public function getCacheRepository();
|
||||
|
||||
/**
|
||||
* Get Cache key for the method
|
||||
*
|
||||
* @param $method
|
||||
* @param $args
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCacheKey($method, $args = null);
|
||||
|
||||
/**
|
||||
* Get cache minutes
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCacheMinutes();
|
||||
|
||||
|
||||
/**
|
||||
* Skip Cache
|
||||
*
|
||||
* @param bool $status
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function skipCache($status = true);
|
||||
}
|
||||
20
vendor/prettus/l5-repository/src/Prettus/Repository/Contracts/CriteriaInterface.php
vendored
Normal file
20
vendor/prettus/l5-repository/src/Prettus/Repository/Contracts/CriteriaInterface.php
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
namespace Prettus\Repository\Contracts;
|
||||
|
||||
/**
|
||||
* Interface CriteriaInterface
|
||||
* @package Prettus\Repository\Contracts
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
interface CriteriaInterface
|
||||
{
|
||||
/**
|
||||
* Apply criteria in query repository
|
||||
*
|
||||
* @param $model
|
||||
* @param RepositoryInterface $repository
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function apply($model, RepositoryInterface $repository);
|
||||
}
|
||||
22
vendor/prettus/l5-repository/src/Prettus/Repository/Contracts/Presentable.php
vendored
Normal file
22
vendor/prettus/l5-repository/src/Prettus/Repository/Contracts/Presentable.php
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
namespace Prettus\Repository\Contracts;
|
||||
|
||||
/**
|
||||
* Interface Presentable
|
||||
* @package Prettus\Repository\Contracts
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
interface Presentable
|
||||
{
|
||||
/**
|
||||
* @param PresenterInterface $presenter
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function setPresenter(PresenterInterface $presenter);
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function presenter();
|
||||
}
|
||||
19
vendor/prettus/l5-repository/src/Prettus/Repository/Contracts/PresenterInterface.php
vendored
Normal file
19
vendor/prettus/l5-repository/src/Prettus/Repository/Contracts/PresenterInterface.php
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
namespace Prettus\Repository\Contracts;
|
||||
|
||||
/**
|
||||
* Interface PresenterInterface
|
||||
* @package Prettus\Repository\Contracts
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
interface PresenterInterface
|
||||
{
|
||||
/**
|
||||
* Prepare data to present
|
||||
*
|
||||
* @param $data
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function present($data);
|
||||
}
|
||||
64
vendor/prettus/l5-repository/src/Prettus/Repository/Contracts/RepositoryCriteriaInterface.php
vendored
Normal file
64
vendor/prettus/l5-repository/src/Prettus/Repository/Contracts/RepositoryCriteriaInterface.php
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
namespace Prettus\Repository\Contracts;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
|
||||
/**
|
||||
* Interface RepositoryCriteriaInterface
|
||||
* @package Prettus\Repository\Contracts
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
interface RepositoryCriteriaInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Push Criteria for filter the query
|
||||
*
|
||||
* @param $criteria
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function pushCriteria($criteria);
|
||||
|
||||
/**
|
||||
* Pop Criteria
|
||||
*
|
||||
* @param $criteria
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function popCriteria($criteria);
|
||||
|
||||
/**
|
||||
* Get Collection of Criteria
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getCriteria();
|
||||
|
||||
/**
|
||||
* Find data by Criteria
|
||||
*
|
||||
* @param CriteriaInterface $criteria
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getByCriteria(CriteriaInterface $criteria);
|
||||
|
||||
/**
|
||||
* Skip Criteria
|
||||
*
|
||||
* @param bool $status
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function skipCriteria($status = true);
|
||||
|
||||
/**
|
||||
* Reset all Criterias
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function resetCriteria();
|
||||
}
|
||||
319
vendor/prettus/l5-repository/src/Prettus/Repository/Contracts/RepositoryInterface.php
vendored
Normal file
319
vendor/prettus/l5-repository/src/Prettus/Repository/Contracts/RepositoryInterface.php
vendored
Normal file
@@ -0,0 +1,319 @@
|
||||
<?php
|
||||
namespace Prettus\Repository\Contracts;
|
||||
|
||||
/**
|
||||
* Interface RepositoryInterface
|
||||
* @package Prettus\Repository\Contracts
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
interface RepositoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Retrieve data array for populate field select
|
||||
*
|
||||
* @param string $column
|
||||
* @param string|null $key
|
||||
*
|
||||
* @return \Illuminate\Support\Collection|array
|
||||
*/
|
||||
public function lists($column, $key = null);
|
||||
|
||||
/**
|
||||
* Retrieve data array for populate field select
|
||||
* Compatible with Laravel 5.3
|
||||
* @param string $column
|
||||
* @param string|null $key
|
||||
*
|
||||
* @return \Illuminate\Support\Collection|array
|
||||
*/
|
||||
public function pluck($column, $key = null);
|
||||
|
||||
/**
|
||||
* Sync relations
|
||||
*
|
||||
* @param $id
|
||||
* @param $relation
|
||||
* @param $attributes
|
||||
* @param bool $detaching
|
||||
* @return mixed
|
||||
*/
|
||||
public function sync($id, $relation, $attributes, $detaching = true);
|
||||
|
||||
/**
|
||||
* SyncWithoutDetaching
|
||||
*
|
||||
* @param $id
|
||||
* @param $relation
|
||||
* @param $attributes
|
||||
* @return mixed
|
||||
*/
|
||||
public function syncWithoutDetaching($id, $relation, $attributes);
|
||||
|
||||
/**
|
||||
* Retrieve all data of repository
|
||||
*
|
||||
* @param array $columns
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function all($columns = ['*']);
|
||||
|
||||
/**
|
||||
* Retrieve all data of repository, paginated
|
||||
*
|
||||
* @param null $limit
|
||||
* @param array $columns
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function paginate($limit = null, $columns = ['*']);
|
||||
|
||||
/**
|
||||
* Retrieve all data of repository, simple paginated
|
||||
*
|
||||
* @param null $limit
|
||||
* @param array $columns
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function simplePaginate($limit = null, $columns = ['*']);
|
||||
|
||||
/**
|
||||
* Find data by id
|
||||
*
|
||||
* @param $id
|
||||
* @param array $columns
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function find($id, $columns = ['*']);
|
||||
|
||||
/**
|
||||
* Find data by field and value
|
||||
*
|
||||
* @param $field
|
||||
* @param $value
|
||||
* @param array $columns
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function findByField($field, $value, $columns = ['*']);
|
||||
|
||||
/**
|
||||
* Find data by multiple fields
|
||||
*
|
||||
* @param array $where
|
||||
* @param array $columns
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function findWhere(array $where, $columns = ['*']);
|
||||
|
||||
/**
|
||||
* Find data by multiple values in one field
|
||||
*
|
||||
* @param $field
|
||||
* @param array $values
|
||||
* @param array $columns
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function findWhereIn($field, array $values, $columns = ['*']);
|
||||
|
||||
/**
|
||||
* Find data by excluding multiple values in one field
|
||||
*
|
||||
* @param $field
|
||||
* @param array $values
|
||||
* @param array $columns
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function findWhereNotIn($field, array $values, $columns = ['*']);
|
||||
|
||||
/**
|
||||
* Find data by between values in one field
|
||||
*
|
||||
* @param $field
|
||||
* @param array $values
|
||||
* @param array $columns
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function findWhereBetween($field, array $values, $columns = ['*']);
|
||||
|
||||
/**
|
||||
* Save a new entity in repository
|
||||
*
|
||||
* @param array $attributes
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function create(array $attributes);
|
||||
|
||||
/**
|
||||
* Update a entity in repository by id
|
||||
*
|
||||
* @param array $attributes
|
||||
* @param $id
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function update(array $attributes, $id);
|
||||
|
||||
/**
|
||||
* Update or Create an entity in repository
|
||||
*
|
||||
* @throws ValidatorException
|
||||
*
|
||||
* @param array $attributes
|
||||
* @param array $values
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function updateOrCreate(array $attributes, array $values = []);
|
||||
|
||||
/**
|
||||
* Delete a entity in repository by id
|
||||
*
|
||||
* @param $id
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function delete($id);
|
||||
|
||||
/**
|
||||
* Order collection by a given column
|
||||
*
|
||||
* @param string $column
|
||||
* @param string $direction
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function orderBy($column, $direction = 'asc');
|
||||
|
||||
/**
|
||||
* Load relations
|
||||
*
|
||||
* @param $relations
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function with($relations);
|
||||
|
||||
/**
|
||||
* Load relation with closure
|
||||
*
|
||||
* @param string $relation
|
||||
* @param closure $closure
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function whereHas($relation, $closure);
|
||||
|
||||
/**
|
||||
* Add subselect queries to count the relations.
|
||||
*
|
||||
* @param mixed $relations
|
||||
* @return $this
|
||||
*/
|
||||
public function withCount($relations);
|
||||
|
||||
/**
|
||||
* Set hidden fields
|
||||
*
|
||||
* @param array $fields
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function hidden(array $fields);
|
||||
|
||||
/**
|
||||
* Set visible fields
|
||||
*
|
||||
* @param array $fields
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function visible(array $fields);
|
||||
|
||||
/**
|
||||
* Query Scope
|
||||
*
|
||||
* @param \Closure $scope
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function scopeQuery(\Closure $scope);
|
||||
|
||||
/**
|
||||
* Reset Query Scope
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function resetScope();
|
||||
|
||||
/**
|
||||
* Get Searchable Fields
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getFieldsSearchable();
|
||||
|
||||
/**
|
||||
* Set Presenter
|
||||
*
|
||||
* @param $presenter
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function setPresenter($presenter);
|
||||
|
||||
/**
|
||||
* Skip Presenter Wrapper
|
||||
*
|
||||
* @param bool $status
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function skipPresenter($status = true);
|
||||
|
||||
/**
|
||||
* Retrieve first data of repository, or return new Entity
|
||||
*
|
||||
* @param array $attributes
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function firstOrNew(array $attributes = []);
|
||||
|
||||
/**
|
||||
* Retrieve first data of repository, or create new Entity
|
||||
*
|
||||
* @param array $attributes
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function firstOrCreate(array $attributes = []);
|
||||
|
||||
/**
|
||||
* Trigger static method calls to the model
|
||||
*
|
||||
* @param $method
|
||||
* @param $arguments
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function __callStatic($method, $arguments);
|
||||
|
||||
/**
|
||||
* Trigger method calls to the model
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $arguments
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($method, $arguments);
|
||||
}
|
||||
15
vendor/prettus/l5-repository/src/Prettus/Repository/Contracts/Transformable.php
vendored
Normal file
15
vendor/prettus/l5-repository/src/Prettus/Repository/Contracts/Transformable.php
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
namespace Prettus\Repository\Contracts;
|
||||
|
||||
/**
|
||||
* Interface Transformable
|
||||
* @package Prettus\Repository\Contracts
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
interface Transformable
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function transform();
|
||||
}
|
||||
267
vendor/prettus/l5-repository/src/Prettus/Repository/Criteria/RequestCriteria.php
vendored
Normal file
267
vendor/prettus/l5-repository/src/Prettus/Repository/Criteria/RequestCriteria.php
vendored
Normal file
@@ -0,0 +1,267 @@
|
||||
<?php
|
||||
namespace Prettus\Repository\Criteria;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Str;
|
||||
use Prettus\Repository\Contracts\CriteriaInterface;
|
||||
use Prettus\Repository\Contracts\RepositoryInterface;
|
||||
|
||||
/**
|
||||
* Class RequestCriteria
|
||||
* @package Prettus\Repository\Criteria
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
class RequestCriteria implements CriteriaInterface
|
||||
{
|
||||
/**
|
||||
* @var \Illuminate\Http\Request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
public function __construct(Request $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Apply criteria in query repository
|
||||
*
|
||||
* @param Builder|Model $model
|
||||
* @param RepositoryInterface $repository
|
||||
*
|
||||
* @return mixed
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function apply($model, RepositoryInterface $repository)
|
||||
{
|
||||
$fieldsSearchable = $repository->getFieldsSearchable();
|
||||
$search = $this->request->get(config('repository.criteria.params.search', 'search'), null);
|
||||
$searchFields = $this->request->get(config('repository.criteria.params.searchFields', 'searchFields'), null);
|
||||
$filter = $this->request->get(config('repository.criteria.params.filter', 'filter'), null);
|
||||
$orderBy = $this->request->get(config('repository.criteria.params.orderBy', 'orderBy'), null);
|
||||
$sortedBy = $this->request->get(config('repository.criteria.params.sortedBy', 'sortedBy'), 'asc');
|
||||
$with = $this->request->get(config('repository.criteria.params.with', 'with'), null);
|
||||
$withCount = $this->request->get(config('repository.criteria.params.withCount', 'withCount'), null);
|
||||
$searchJoin = $this->request->get(config('repository.criteria.params.searchJoin', 'searchJoin'), null);
|
||||
$sortedBy = !empty($sortedBy) ? $sortedBy : 'asc';
|
||||
|
||||
if ($search && is_array($fieldsSearchable) && count($fieldsSearchable)) {
|
||||
|
||||
$searchFields = is_array($searchFields) || is_null($searchFields) ? $searchFields : explode(';', $searchFields);
|
||||
$fields = $this->parserFieldsSearch($fieldsSearchable, $searchFields);
|
||||
$isFirstField = true;
|
||||
$searchData = $this->parserSearchData($search);
|
||||
$search = $this->parserSearchValue($search);
|
||||
$modelForceAndWhere = strtolower($searchJoin) === 'and';
|
||||
|
||||
$model = $model->where(function ($query) use ($fields, $search, $searchData, $isFirstField, $modelForceAndWhere) {
|
||||
/** @var Builder $query */
|
||||
|
||||
foreach ($fields as $field => $condition) {
|
||||
|
||||
if (is_numeric($field)) {
|
||||
$field = $condition;
|
||||
$condition = "=";
|
||||
}
|
||||
|
||||
$value = null;
|
||||
|
||||
$condition = trim(strtolower($condition));
|
||||
|
||||
if (isset($searchData[$field])) {
|
||||
$value = ($condition == "like" || $condition == "ilike") ? "%{$searchData[$field]}%" : $searchData[$field];
|
||||
} else {
|
||||
if (!is_null($search)) {
|
||||
$value = ($condition == "like" || $condition == "ilike") ? "%{$search}%" : $search;
|
||||
}
|
||||
}
|
||||
|
||||
$relation = null;
|
||||
if(stripos($field, '.')) {
|
||||
$explode = explode('.', $field);
|
||||
$field = array_pop($explode);
|
||||
$relation = implode('.', $explode);
|
||||
}
|
||||
$modelTableName = $query->getModel()->getTable();
|
||||
if ( $isFirstField || $modelForceAndWhere ) {
|
||||
if (!is_null($value)) {
|
||||
if(!is_null($relation)) {
|
||||
$query->whereHas($relation, function($query) use($field,$condition,$value) {
|
||||
$query->where($field,$condition,$value);
|
||||
});
|
||||
} else {
|
||||
$query->where($modelTableName.'.'.$field,$condition,$value);
|
||||
}
|
||||
$isFirstField = false;
|
||||
}
|
||||
} else {
|
||||
if (!is_null($value)) {
|
||||
if(!is_null($relation)) {
|
||||
$query->orWhereHas($relation, function($query) use($field,$condition,$value) {
|
||||
$query->where($field,$condition,$value);
|
||||
});
|
||||
} else {
|
||||
$query->orWhere($modelTableName.'.'.$field, $condition, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (isset($orderBy) && !empty($orderBy)) {
|
||||
$split = explode('|', $orderBy);
|
||||
if(count($split) > 1) {
|
||||
/*
|
||||
* ex.
|
||||
* products|description -> join products on current_table.product_id = products.id order by description
|
||||
*
|
||||
* products:custom_id|products.description -> join products on current_table.custom_id = products.id order
|
||||
* by products.description (in case both tables have same column name)
|
||||
*/
|
||||
$table = $model->getModel()->getTable();
|
||||
$sortTable = $split[0];
|
||||
$sortColumn = $split[1];
|
||||
|
||||
$split = explode(':', $sortTable);
|
||||
if(count($split) > 1) {
|
||||
$sortTable = $split[0];
|
||||
$keyName = $table.'.'.$split[1];
|
||||
} else {
|
||||
/*
|
||||
* If you do not define which column to use as a joining column on current table, it will
|
||||
* use a singular of a join table appended with _id
|
||||
*
|
||||
* ex.
|
||||
* products -> product_id
|
||||
*/
|
||||
$prefix = Str::singular($sortTable);
|
||||
$keyName = $table.'.'.$prefix.'_id';
|
||||
}
|
||||
|
||||
$model = $model
|
||||
->leftJoin($sortTable, $keyName, '=', $sortTable.'.id')
|
||||
->orderBy($sortColumn, $sortedBy)
|
||||
->addSelect($table.'.*');
|
||||
} else {
|
||||
$model = $model->orderBy($orderBy, $sortedBy);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($filter) && !empty($filter)) {
|
||||
if (is_string($filter)) {
|
||||
$filter = explode(';', $filter);
|
||||
}
|
||||
|
||||
$model = $model->select($filter);
|
||||
}
|
||||
|
||||
if ($with) {
|
||||
$with = explode(';', $with);
|
||||
$model = $model->with($with);
|
||||
}
|
||||
|
||||
if ($withCount) {
|
||||
$withCount = explode(';', $withCount);
|
||||
$model = $model->withCount($withCount);
|
||||
}
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $search
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function parserSearchData($search)
|
||||
{
|
||||
$searchData = [];
|
||||
|
||||
if (stripos($search, ':')) {
|
||||
$fields = explode(';', $search);
|
||||
|
||||
foreach ($fields as $row) {
|
||||
try {
|
||||
list($field, $value) = explode(':', $row);
|
||||
$searchData[$field] = $value;
|
||||
} catch (\Exception $e) {
|
||||
//Surround offset error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $searchData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $search
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
protected function parserSearchValue($search)
|
||||
{
|
||||
|
||||
if (stripos($search, ';') || stripos($search, ':')) {
|
||||
$values = explode(';', $search);
|
||||
foreach ($values as $value) {
|
||||
$s = explode(':', $value);
|
||||
if (count($s) == 1) {
|
||||
return $s[0];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return $search;
|
||||
}
|
||||
|
||||
|
||||
protected function parserFieldsSearch(array $fields = [], array $searchFields = null)
|
||||
{
|
||||
if (!is_null($searchFields) && count($searchFields)) {
|
||||
$acceptedConditions = config('repository.criteria.acceptedConditions', [
|
||||
'=',
|
||||
'like'
|
||||
]);
|
||||
$originalFields = $fields;
|
||||
$fields = [];
|
||||
|
||||
foreach ($searchFields as $index => $field) {
|
||||
$field_parts = explode(':', $field);
|
||||
$temporaryIndex = array_search($field_parts[0], $originalFields);
|
||||
|
||||
if (count($field_parts) == 2) {
|
||||
if (in_array($field_parts[1], $acceptedConditions)) {
|
||||
unset($originalFields[$temporaryIndex]);
|
||||
$field = $field_parts[0];
|
||||
$condition = $field_parts[1];
|
||||
$originalFields[$field] = $condition;
|
||||
$searchFields[$index] = $field;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($originalFields as $field => $condition) {
|
||||
if (is_numeric($field)) {
|
||||
$field = $condition;
|
||||
$condition = "=";
|
||||
}
|
||||
if (in_array($field, $searchFields)) {
|
||||
$fields[$field] = $condition;
|
||||
}
|
||||
}
|
||||
|
||||
if (count($fields) == 0) {
|
||||
throw new \Exception(trans('repository::criteria.fields_not_accepted', ['field' => implode(',', $searchFields)]));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
}
|
||||
1098
vendor/prettus/l5-repository/src/Prettus/Repository/Eloquent/BaseRepository.php
vendored
Normal file
1098
vendor/prettus/l5-repository/src/Prettus/Repository/Eloquent/BaseRepository.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
15
vendor/prettus/l5-repository/src/Prettus/Repository/Events/RepositoryEntityCreated.php
vendored
Normal file
15
vendor/prettus/l5-repository/src/Prettus/Repository/Events/RepositoryEntityCreated.php
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
namespace Prettus\Repository\Events;
|
||||
|
||||
/**
|
||||
* Class RepositoryEntityCreated
|
||||
* @package Prettus\Repository\Events
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
class RepositoryEntityCreated extends RepositoryEventBase
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $action = "created";
|
||||
}
|
||||
15
vendor/prettus/l5-repository/src/Prettus/Repository/Events/RepositoryEntityDeleted.php
vendored
Normal file
15
vendor/prettus/l5-repository/src/Prettus/Repository/Events/RepositoryEntityDeleted.php
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
namespace Prettus\Repository\Events;
|
||||
|
||||
/**
|
||||
* Class RepositoryEntityDeleted
|
||||
* @package Prettus\Repository\Events
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
class RepositoryEntityDeleted extends RepositoryEventBase
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $action = "deleted";
|
||||
}
|
||||
15
vendor/prettus/l5-repository/src/Prettus/Repository/Events/RepositoryEntityUpdated.php
vendored
Normal file
15
vendor/prettus/l5-repository/src/Prettus/Repository/Events/RepositoryEntityUpdated.php
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
namespace Prettus\Repository\Events;
|
||||
|
||||
/**
|
||||
* Class RepositoryEntityUpdated
|
||||
* @package Prettus\Repository\Events
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
class RepositoryEntityUpdated extends RepositoryEventBase
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $action = "updated";
|
||||
}
|
||||
62
vendor/prettus/l5-repository/src/Prettus/Repository/Events/RepositoryEventBase.php
vendored
Normal file
62
vendor/prettus/l5-repository/src/Prettus/Repository/Events/RepositoryEventBase.php
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
namespace Prettus\Repository\Events;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Prettus\Repository\Contracts\RepositoryInterface;
|
||||
|
||||
/**
|
||||
* Class RepositoryEventBase
|
||||
* @package Prettus\Repository\Events
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
abstract class RepositoryEventBase
|
||||
{
|
||||
/**
|
||||
* @var Model
|
||||
*/
|
||||
protected $model;
|
||||
|
||||
/**
|
||||
* @var RepositoryInterface
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $action;
|
||||
|
||||
/**
|
||||
* @param RepositoryInterface $repository
|
||||
* @param Model $model
|
||||
*/
|
||||
public function __construct(RepositoryInterface $repository, Model $model)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
$this->model = $model;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Model
|
||||
*/
|
||||
public function getModel()
|
||||
{
|
||||
return $this->model;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return RepositoryInterface
|
||||
*/
|
||||
public function getRepository()
|
||||
{
|
||||
return $this->repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAction()
|
||||
{
|
||||
return $this->action;
|
||||
}
|
||||
}
|
||||
14
vendor/prettus/l5-repository/src/Prettus/Repository/Exceptions/RepositoryException.php
vendored
Normal file
14
vendor/prettus/l5-repository/src/Prettus/Repository/Exceptions/RepositoryException.php
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
namespace Prettus\Repository\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Class RepositoryException
|
||||
* @package Prettus\Repository\Exceptions
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
class RepositoryException extends Exception
|
||||
{
|
||||
|
||||
}
|
||||
149
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/ApiControllerGenerator.php
vendored
Normal file
149
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/ApiControllerGenerator.php
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
namespace Prettus\Repository\Generators;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Class ApiControllerGenerator
|
||||
* @package Prettus\Repository\Generators
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
class ApiControllerGenerator extends Generator
|
||||
{
|
||||
|
||||
/**
|
||||
* Get stub name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $stub = 'api/controller';
|
||||
|
||||
/**
|
||||
* Get root namespace.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRootNamespace()
|
||||
{
|
||||
return str_replace('/', '\\', parent::getRootNamespace() . parent::getConfigGeneratorClassPath($this->getPathConfigNode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get generator path config node.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPathConfigNode()
|
||||
{
|
||||
return 'controllers';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get destination path for generated file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPath()
|
||||
{
|
||||
return $this->getBasePath() . '/' . parent::getConfigGeneratorClassPath($this->getPathConfigNode(), true) . '/' . $this->getControllerName() . 'Controller.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get base path of destination file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBasePath()
|
||||
{
|
||||
return config('repository.generator.basePath', app()->path());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets controller name based on model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getControllerName()
|
||||
{
|
||||
|
||||
return ucfirst($this->getPluralName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets plural name based on model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPluralName()
|
||||
{
|
||||
|
||||
return Str::plural(lcfirst(ucwords($this->getClass())));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get array replacements.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getReplacements()
|
||||
{
|
||||
|
||||
return array_merge(parent::getReplacements(), [
|
||||
'controller' => $this->getControllerName(),
|
||||
'plural' => $this->getPluralName(),
|
||||
'singular' => $this->getSingularName(),
|
||||
'validator' => $this->getValidator(),
|
||||
'repository' => $this->getRepository(),
|
||||
'appname' => $this->getAppNamespace(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets singular name based on model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSingularName()
|
||||
{
|
||||
return Str::singular(lcfirst(ucwords($this->getClass())));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets validator full class name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getValidator()
|
||||
{
|
||||
$validatorGenerator = new ValidatorGenerator([
|
||||
'name' => $this->name,
|
||||
]);
|
||||
|
||||
$validator = $validatorGenerator->getRootNamespace() . '\\' . $validatorGenerator->getName();
|
||||
|
||||
return 'use ' . str_replace([
|
||||
"\\",
|
||||
'/'
|
||||
], '\\', $validator) . 'Validator;';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets repository full class name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRepository()
|
||||
{
|
||||
$repositoryGenerator = new RepositoryInterfaceGenerator([
|
||||
'name' => $this->name,
|
||||
]);
|
||||
|
||||
$repository = $repositoryGenerator->getRootNamespace() . '\\' . $repositoryGenerator->getName();
|
||||
|
||||
return 'use ' . str_replace([
|
||||
"\\",
|
||||
'/'
|
||||
], '\\', $repository) . 'Repository;';
|
||||
}
|
||||
}
|
||||
149
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/ApiRepositoryEloquentGenerator.php
vendored
Normal file
149
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/ApiRepositoryEloquentGenerator.php
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
namespace Prettus\Repository\Generators;
|
||||
|
||||
use Prettus\Repository\Generators\Migrations\SchemaParser;
|
||||
|
||||
/**
|
||||
* Class ApiRepositoryEloquentGenerator
|
||||
* @package Prettus\Repository\Generators
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
class ApiRepositoryEloquentGenerator extends Generator
|
||||
{
|
||||
|
||||
/**
|
||||
* Get stub name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $stub = 'api/eloquent';
|
||||
|
||||
/**
|
||||
* Get root namespace.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRootNamespace()
|
||||
{
|
||||
return parent::getRootNamespace() . parent::getConfigGeneratorClassPath($this->getPathConfigNode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get generator path config node.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPathConfigNode()
|
||||
{
|
||||
return 'repositories';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get destination path for generated file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPath()
|
||||
{
|
||||
return $this->getBasePath() . '/' . parent::getConfigGeneratorClassPath($this->getPathConfigNode(), true) . '/' . $this->getName() . 'RepositoryEloquent.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get base path of destination file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBasePath()
|
||||
{
|
||||
return config('repository.generator.basePath', app()->path());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get array replacements.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getReplacements()
|
||||
{
|
||||
$repository = parent::getRootNamespace() . parent::getConfigGeneratorClassPath('interfaces') . '\\' . $this->name . 'Repository;';
|
||||
$repository = str_replace([
|
||||
"\\",
|
||||
'/'
|
||||
], '\\', $repository);
|
||||
|
||||
return array_merge(parent::getReplacements(), [
|
||||
'fillable' => $this->getFillable(),
|
||||
'use_validator' => $this->getValidatorUse(),
|
||||
'validator' => $this->getValidatorMethod(),
|
||||
'repository' => $repository,
|
||||
'model' => isset($this->options['model']) ? $this->options['model'] : ''
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fillable attributes.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFillable()
|
||||
{
|
||||
if (!$this->fillable) {
|
||||
return '[]';
|
||||
}
|
||||
$results = '[' . PHP_EOL;
|
||||
|
||||
foreach ($this->getSchemaParser()->toArray() as $column => $value) {
|
||||
$results .= "\t\t'{$column}'," . PHP_EOL;
|
||||
}
|
||||
|
||||
return $results . "\t" . ']';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get schema parser.
|
||||
*
|
||||
* @return SchemaParser
|
||||
*/
|
||||
public function getSchemaParser()
|
||||
{
|
||||
return new SchemaParser($this->fillable);
|
||||
}
|
||||
|
||||
public function getValidatorUse()
|
||||
{
|
||||
$validator = $this->getValidator();
|
||||
|
||||
return "use {$validator};";
|
||||
}
|
||||
|
||||
|
||||
public function getValidator()
|
||||
{
|
||||
$validatorGenerator = new ValidatorGenerator([
|
||||
'name' => $this->name,
|
||||
'rules' => $this->rules,
|
||||
'force' => $this->force,
|
||||
]);
|
||||
|
||||
$validator = $validatorGenerator->getRootNamespace() . '\\' . $validatorGenerator->getName();
|
||||
|
||||
return str_replace([
|
||||
"\\",
|
||||
'/'
|
||||
], '\\', $validator) . 'Validator';
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function getValidatorMethod()
|
||||
{
|
||||
if ($this->validator != 'yes') {
|
||||
return '';
|
||||
}
|
||||
|
||||
$class = $this->getClass();
|
||||
|
||||
return '/**' . PHP_EOL . ' * Specify Validator class name' . PHP_EOL . ' *' . PHP_EOL . ' * @return mixed' . PHP_EOL . ' */' . PHP_EOL . ' public function validator()' . PHP_EOL . ' {' . PHP_EOL . PHP_EOL . ' return ' . $class . 'Validator::class;' . PHP_EOL . ' }' . PHP_EOL;
|
||||
|
||||
}
|
||||
}
|
||||
128
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/BindingsGenerator.php
vendored
Normal file
128
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/BindingsGenerator.php
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
namespace Prettus\Repository\Generators;
|
||||
|
||||
/**
|
||||
* Class BindingsGenerator
|
||||
* @package Prettus\Repository\Generators
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
class BindingsGenerator extends Generator
|
||||
{
|
||||
|
||||
/**
|
||||
* The placeholder for repository bindings
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $bindPlaceholder = '//:end-bindings:';
|
||||
/**
|
||||
* Get stub name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $stub = 'bindings/bindings';
|
||||
|
||||
public function run()
|
||||
{
|
||||
|
||||
|
||||
// Add entity repository binding to the repository service provider
|
||||
$provider = \File::get($this->getPath());
|
||||
$repositoryInterface = '\\' . $this->getRepository() . "::class";
|
||||
$repositoryEloquent = '\\' . $this->getEloquentRepository() . "::class";
|
||||
\File::put($this->getPath(), str_replace($this->bindPlaceholder, "\$this->app->bind({$repositoryInterface}, $repositoryEloquent);" . PHP_EOL . ' ' . $this->bindPlaceholder, $provider));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get destination path for generated file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPath()
|
||||
{
|
||||
return $this->getBasePath() . '/Providers/' . parent::getConfigGeneratorClassPath($this->getPathConfigNode(), true) . '.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get base path of destination file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBasePath()
|
||||
{
|
||||
return config('repository.generator.basePath', app()->path());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get generator path config node.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPathConfigNode()
|
||||
{
|
||||
return 'provider';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets repository full class name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRepository()
|
||||
{
|
||||
$repositoryGenerator = new RepositoryInterfaceGenerator([
|
||||
'name' => $this->name,
|
||||
]);
|
||||
|
||||
$repository = $repositoryGenerator->getRootNamespace() . '\\' . $repositoryGenerator->getName();
|
||||
|
||||
return str_replace([
|
||||
"\\",
|
||||
'/'
|
||||
], '\\', $repository) . 'Repository';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets eloquent repository full class name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEloquentRepository()
|
||||
{
|
||||
$repositoryGenerator = new RepositoryEloquentGenerator([
|
||||
'name' => $this->name,
|
||||
]);
|
||||
|
||||
$repository = $repositoryGenerator->getRootNamespace() . '\\' . $repositoryGenerator->getName();
|
||||
|
||||
return str_replace([
|
||||
"\\",
|
||||
'/'
|
||||
], '\\', $repository) . 'RepositoryEloquent';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get root namespace.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRootNamespace()
|
||||
{
|
||||
return parent::getRootNamespace() . parent::getConfigGeneratorClassPath($this->getPathConfigNode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get array replacements.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getReplacements()
|
||||
{
|
||||
|
||||
return array_merge(parent::getReplacements(), [
|
||||
'repository' => $this->getRepository(),
|
||||
'eloquent' => $this->getEloquentRepository(),
|
||||
'placeholder' => $this->bindPlaceholder,
|
||||
]);
|
||||
}
|
||||
}
|
||||
134
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Commands/ApiControllerCommand.php
vendored
Normal file
134
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Commands/ApiControllerCommand.php
vendored
Normal file
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
namespace Prettus\Repository\Generators\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Collection;
|
||||
use Prettus\Repository\Generators\ApiControllerGenerator;
|
||||
use Prettus\Repository\Generators\FileAlreadyExistsException;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
/**
|
||||
* Class ApiControllerCommand
|
||||
* @package Prettus\Repository\Generators\Commands
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
class ApiControllerCommand extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* The name of command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'make:api-resource';
|
||||
|
||||
/**
|
||||
* The description of command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a new RESTful controller for api.';
|
||||
|
||||
/**
|
||||
* The type of class being generated.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $type = 'Controller';
|
||||
|
||||
/**
|
||||
* ApiControllerCommand constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->name = ((float) app()->version() >= 5.5 ? 'make:rest-controller' : 'make:api-resource');
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command.
|
||||
*
|
||||
* @see fire()
|
||||
* @return void
|
||||
*/
|
||||
public function handle(){
|
||||
$this->laravel->call([$this, 'fire'], func_get_args());
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
try {
|
||||
// Generate requests for api controller
|
||||
$this->call('make:request', [
|
||||
'name' => $this->argument('name') . '/IndexRequest'
|
||||
]);
|
||||
$this->call('make:request', [
|
||||
'name' => $this->argument('name') . '/CreateRequest'
|
||||
]);
|
||||
$this->call('make:request', [
|
||||
'name' => $this->argument('name') . '/ShowRequest'
|
||||
]);
|
||||
$this->call('make:request', [
|
||||
'name' => $this->argument('name') . '/UpdateRequest'
|
||||
]);
|
||||
$this->call('make:request', [
|
||||
'name' => $this->argument('name') . '/DestroyRequest'
|
||||
]);
|
||||
|
||||
(new ApiControllerGenerator([
|
||||
'name' => $this->argument('name'),
|
||||
'force' => $this->option('force'),
|
||||
]))->run();
|
||||
|
||||
$this->info($this->type . ' created successfully.');
|
||||
|
||||
} catch (FileAlreadyExistsException $e) {
|
||||
$this->error($this->type . ' already exists!');
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The array of command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getArguments()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'name',
|
||||
InputArgument::REQUIRED,
|
||||
'The name of model for which the controller is being generated.',
|
||||
null
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The array of command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getOptions()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'force',
|
||||
'f',
|
||||
InputOption::VALUE_NONE,
|
||||
'Force the creation if file already exists.',
|
||||
null
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
191
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Commands/ApiRepositoryCommand.php
vendored
Normal file
191
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Commands/ApiRepositoryCommand.php
vendored
Normal file
@@ -0,0 +1,191 @@
|
||||
<?php
|
||||
namespace Prettus\Repository\Generators\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Str;
|
||||
use Prettus\Repository\Generators\FileAlreadyExistsException;
|
||||
use Prettus\Repository\Generators\MigrationGenerator;
|
||||
use Prettus\Repository\Generators\ModelGenerator;
|
||||
use Prettus\Repository\Generators\ApiRepositoryEloquentGenerator;
|
||||
use Prettus\Repository\Generators\RepositoryInterfaceGenerator;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
/**
|
||||
* Class ApiRepositoryCommand
|
||||
* @package Prettus\Repository\Generators\Commands
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
class ApiRepositoryCommand extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* The name of command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'make:api-repository';
|
||||
|
||||
/**
|
||||
* The description of command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a new repository for api.';
|
||||
|
||||
/**
|
||||
* The type of class being generated.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $type = 'Repository';
|
||||
|
||||
/**
|
||||
* @var Collection
|
||||
*/
|
||||
protected $generators = null;
|
||||
|
||||
|
||||
/**
|
||||
* Execute the command.
|
||||
*
|
||||
* @see fire()
|
||||
* @return void
|
||||
*/
|
||||
public function handle(){
|
||||
$this->laravel->call([$this, 'fire'], func_get_args());
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
$this->generators = new Collection();
|
||||
|
||||
$migrationGenerator = new MigrationGenerator([
|
||||
'name' => 'create_' . Str::snake(Str::plural($this->argument('name'))) . '_table',
|
||||
'fields' => $this->option('fillable'),
|
||||
'force' => $this->option('force'),
|
||||
]);
|
||||
|
||||
if (!$this->option('skip-migration')) {
|
||||
$this->generators->push($migrationGenerator);
|
||||
}
|
||||
|
||||
$modelGenerator = new ModelGenerator([
|
||||
'name' => $this->argument('name'),
|
||||
'fillable' => $this->option('fillable'),
|
||||
'force' => $this->option('force')
|
||||
]);
|
||||
|
||||
if (!$this->option('skip-model')) {
|
||||
$this->generators->push($modelGenerator);
|
||||
}
|
||||
|
||||
$this->generators->push(new RepositoryInterfaceGenerator([
|
||||
'name' => $this->argument('name'),
|
||||
'force' => $this->option('force'),
|
||||
]));
|
||||
|
||||
foreach ($this->generators as $generator) {
|
||||
$generator->run();
|
||||
}
|
||||
|
||||
$model = $modelGenerator->getRootNamespace() . '\\' . $modelGenerator->getName();
|
||||
$model = str_replace([
|
||||
"\\",
|
||||
'/'
|
||||
], '\\', $model);
|
||||
|
||||
try {
|
||||
(new ApiRepositoryEloquentGenerator([
|
||||
'name' => $this->argument('name'),
|
||||
'rules' => $this->option('rules'),
|
||||
'validator' => $this->option('validator'),
|
||||
'force' => $this->option('force'),
|
||||
'model' => $model
|
||||
]))->run();
|
||||
$this->info("Repository created successfully.");
|
||||
} catch (FileAlreadyExistsException $e) {
|
||||
$this->error($this->type . ' already exists!');
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The array of command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getArguments()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'name',
|
||||
InputArgument::REQUIRED,
|
||||
'The name of class being generated.',
|
||||
null
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The array of command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getOptions()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'fillable',
|
||||
null,
|
||||
InputOption::VALUE_OPTIONAL,
|
||||
'The fillable attributes.',
|
||||
null
|
||||
],
|
||||
[
|
||||
'rules',
|
||||
null,
|
||||
InputOption::VALUE_OPTIONAL,
|
||||
'The rules of validation attributes.',
|
||||
null
|
||||
],
|
||||
[
|
||||
'validator',
|
||||
null,
|
||||
InputOption::VALUE_OPTIONAL,
|
||||
'Adds validator reference to the repository.',
|
||||
null
|
||||
],
|
||||
[
|
||||
'force',
|
||||
'f',
|
||||
InputOption::VALUE_NONE,
|
||||
'Force the creation if file already exists.',
|
||||
null
|
||||
],
|
||||
[
|
||||
'skip-migration',
|
||||
null,
|
||||
InputOption::VALUE_NONE,
|
||||
'Skip the creation of a migration file.',
|
||||
null,
|
||||
],
|
||||
[
|
||||
'skip-model',
|
||||
null,
|
||||
InputOption::VALUE_NONE,
|
||||
'Skip the creation of a model.',
|
||||
null,
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
120
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Commands/BindingsCommand.php
vendored
Normal file
120
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Commands/BindingsCommand.php
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
namespace Prettus\Repository\Generators\Commands;
|
||||
|
||||
use File;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Collection;
|
||||
use Prettus\Repository\Generators\BindingsGenerator;
|
||||
use Prettus\Repository\Generators\FileAlreadyExistsException;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
/**
|
||||
* Class BindingsCommand
|
||||
* @package Prettus\Repository\Generators\Commands
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
class BindingsCommand extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* The name of command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'make:bindings';
|
||||
|
||||
/**
|
||||
* The description of command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Add repository bindings to service provider.';
|
||||
|
||||
/**
|
||||
* The type of class being generated.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $type = 'Bindings';
|
||||
|
||||
/**
|
||||
* Execute the command.
|
||||
*
|
||||
* @see fire()
|
||||
* @return void
|
||||
*/
|
||||
public function handle(){
|
||||
$this->laravel->call([$this, 'fire'], func_get_args());
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
try {
|
||||
$bindingGenerator = new BindingsGenerator([
|
||||
'name' => $this->argument('name'),
|
||||
'force' => $this->option('force'),
|
||||
]);
|
||||
// generate repository service provider
|
||||
if (!file_exists($bindingGenerator->getPath())) {
|
||||
$this->call('make:provider', [
|
||||
'name' => $bindingGenerator->getConfigGeneratorClassPath($bindingGenerator->getPathConfigNode()),
|
||||
]);
|
||||
// placeholder to mark the place in file where to prepend repository bindings
|
||||
$provider = File::get($bindingGenerator->getPath());
|
||||
File::put($bindingGenerator->getPath(), vsprintf(str_replace('//', '%s', $provider), [
|
||||
'//',
|
||||
$bindingGenerator->bindPlaceholder
|
||||
]));
|
||||
}
|
||||
$bindingGenerator->run();
|
||||
$this->info($this->type . ' created successfully.');
|
||||
} catch (FileAlreadyExistsException $e) {
|
||||
$this->error($this->type . ' already exists!');
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The array of command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getArguments()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'name',
|
||||
InputArgument::REQUIRED,
|
||||
'The name of model for which the controller is being generated.',
|
||||
null
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The array of command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getOptions()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'force',
|
||||
'f',
|
||||
InputOption::VALUE_NONE,
|
||||
'Force the creation if file already exists.',
|
||||
null
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
127
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Commands/ControllerCommand.php
vendored
Normal file
127
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Commands/ControllerCommand.php
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
namespace Prettus\Repository\Generators\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Collection;
|
||||
use Prettus\Repository\Generators\ControllerGenerator;
|
||||
use Prettus\Repository\Generators\FileAlreadyExistsException;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
/**
|
||||
* Class ControllerCommand
|
||||
* @package Prettus\Repository\Generators\Commands
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
class ControllerCommand extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* The name of command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'make:resource';
|
||||
|
||||
/**
|
||||
* The description of command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a new RESTful controller.';
|
||||
|
||||
/**
|
||||
* The type of class being generated.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $type = 'Controller';
|
||||
|
||||
/**
|
||||
* ControllerCommand constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->name = ((float) app()->version() >= 5.5 ? 'make:rest-controller' : 'make:resource');
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command.
|
||||
*
|
||||
* @see fire()
|
||||
* @return void
|
||||
*/
|
||||
public function handle(){
|
||||
$this->laravel->call([$this, 'fire'], func_get_args());
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
try {
|
||||
// Generate create request for controller
|
||||
$this->call('make:request', [
|
||||
'name' => $this->argument('name') . 'CreateRequest'
|
||||
]);
|
||||
|
||||
// Generate update request for controller
|
||||
$this->call('make:request', [
|
||||
'name' => $this->argument('name') . 'UpdateRequest'
|
||||
]);
|
||||
|
||||
(new ControllerGenerator([
|
||||
'name' => $this->argument('name'),
|
||||
'force' => $this->option('force'),
|
||||
]))->run();
|
||||
|
||||
$this->info($this->type . ' created successfully.');
|
||||
|
||||
} catch (FileAlreadyExistsException $e) {
|
||||
$this->error($this->type . ' already exists!');
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The array of command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getArguments()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'name',
|
||||
InputArgument::REQUIRED,
|
||||
'The name of model for which the controller is being generated.',
|
||||
null
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The array of command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getOptions()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'force',
|
||||
'f',
|
||||
InputOption::VALUE_NONE,
|
||||
'Force the creation if file already exists.',
|
||||
null
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
103
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Commands/CriteriaCommand.php
vendored
Normal file
103
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Commands/CriteriaCommand.php
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace Prettus\Repository\Generators\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Prettus\Repository\Generators\CriteriaGenerator;
|
||||
use Prettus\Repository\Generators\FileAlreadyExistsException;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
/**
|
||||
* Class CriteriaCommand
|
||||
* @package Prettus\Repository\Generators\Commands
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
class CriteriaCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name of command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'make:criteria';
|
||||
|
||||
/**
|
||||
* The description of command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a new criteria.';
|
||||
|
||||
/**
|
||||
* The type of class being generated.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $type = 'Criteria';
|
||||
|
||||
/**
|
||||
* Execute the command.
|
||||
*
|
||||
* @see fire()
|
||||
* @return void
|
||||
*/
|
||||
public function handle(){
|
||||
$this->laravel->call([$this, 'fire'], func_get_args());
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
try {
|
||||
(new CriteriaGenerator([
|
||||
'name' => $this->argument('name'),
|
||||
'force' => $this->option('force'),
|
||||
]))->run();
|
||||
|
||||
$this->info("Criteria created successfully.");
|
||||
} catch (FileAlreadyExistsException $ex) {
|
||||
$this->error($this->type . ' already exists!');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The array of command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getArguments()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'name',
|
||||
InputArgument::REQUIRED,
|
||||
'The name of class being generated.',
|
||||
null
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* The array of command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getOptions()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'force',
|
||||
'f',
|
||||
InputOption::VALUE_NONE,
|
||||
'Force the creation if file already exists.',
|
||||
null
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
174
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Commands/EntityCommand.php
vendored
Normal file
174
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Commands/EntityCommand.php
vendored
Normal file
@@ -0,0 +1,174 @@
|
||||
<?php
|
||||
namespace Prettus\Repository\Generators\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Collection;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
/**
|
||||
* Class EntityCommand
|
||||
* @package Prettus\Repository\Generators\Commands
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
class EntityCommand extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* The name of command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'make:entity';
|
||||
|
||||
/**
|
||||
* The description of command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a new entity.';
|
||||
|
||||
/**
|
||||
* @var Collection
|
||||
*/
|
||||
protected $generators = null;
|
||||
|
||||
/**
|
||||
* Execute the command.
|
||||
*
|
||||
* @see fire()
|
||||
* @return void
|
||||
*/
|
||||
public function handle(){
|
||||
$this->laravel->call([$this, 'fire'], func_get_args());
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
|
||||
if (config('repository.generator.api', false)){
|
||||
$resource_args = [
|
||||
'name' => $this->argument('name')
|
||||
];
|
||||
|
||||
// Generate a controller resource
|
||||
$controller_command = ((float) app()->version() >= 5.5 ? 'make:rest-controller' : 'make:api-resource');
|
||||
$this->call($controller_command, $resource_args);
|
||||
|
||||
$this->call('make:api-repository', [
|
||||
'name' => $this->argument('name'),
|
||||
'--fillable' => $this->option('fillable'),
|
||||
'--rules' => $this->option('rules'),
|
||||
'--force' => $this->option('force')
|
||||
]);
|
||||
}
|
||||
else{
|
||||
if ($this->confirm('Would you like to create a Presenter? [y|N]')) {
|
||||
$this->call('make:presenter', [
|
||||
'name' => $this->argument('name'),
|
||||
'--force' => $this->option('force'),
|
||||
]);
|
||||
}
|
||||
|
||||
$validator = $this->option('validator');
|
||||
if (is_null($validator) && $this->confirm('Would you like to create a Validator? [y|N]')) {
|
||||
$validator = 'yes';
|
||||
}
|
||||
|
||||
if ($validator == 'yes') {
|
||||
$this->call('make:validator', [
|
||||
'name' => $this->argument('name'),
|
||||
'--rules' => $this->option('rules'),
|
||||
'--force' => $this->option('force'),
|
||||
]);
|
||||
}
|
||||
|
||||
if ($this->confirm('Would you like to create a Controller? [y|N]')) {
|
||||
|
||||
$resource_args = [
|
||||
'name' => $this->argument('name')
|
||||
];
|
||||
|
||||
// Generate a controller resource
|
||||
$controller_command = ((float) app()->version() >= 5.5 ? 'make:rest-controller' : 'make:resource');
|
||||
$this->call($controller_command, $resource_args);
|
||||
}
|
||||
|
||||
$this->call('make:repository', [
|
||||
'name' => $this->argument('name'),
|
||||
'--fillable' => $this->option('fillable'),
|
||||
'--rules' => $this->option('rules'),
|
||||
'--validator' => $validator,
|
||||
'--force' => $this->option('force')
|
||||
]);
|
||||
}
|
||||
|
||||
$this->call('make:bindings', [
|
||||
'name' => $this->argument('name'),
|
||||
'--force' => $this->option('force')
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The array of command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getArguments()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'name',
|
||||
InputArgument::REQUIRED,
|
||||
'The name of class being generated.',
|
||||
null
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The array of command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getOptions()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'fillable',
|
||||
null,
|
||||
InputOption::VALUE_OPTIONAL,
|
||||
'The fillable attributes.',
|
||||
null
|
||||
],
|
||||
[
|
||||
'rules',
|
||||
null,
|
||||
InputOption::VALUE_OPTIONAL,
|
||||
'The rules of validation attributes.',
|
||||
null
|
||||
],
|
||||
[
|
||||
'validator',
|
||||
null,
|
||||
InputOption::VALUE_OPTIONAL,
|
||||
'Adds validator reference to the repository.',
|
||||
null
|
||||
],
|
||||
[
|
||||
'force',
|
||||
'f',
|
||||
InputOption::VALUE_NONE,
|
||||
'Force the creation if file already exists.',
|
||||
null
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
117
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Commands/PresenterCommand.php
vendored
Normal file
117
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Commands/PresenterCommand.php
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
namespace Prettus\Repository\Generators\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Prettus\Repository\Generators\FileAlreadyExistsException;
|
||||
use Prettus\Repository\Generators\PresenterGenerator;
|
||||
use Prettus\Repository\Generators\TransformerGenerator;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
/**
|
||||
* Class PresenterCommand
|
||||
* @package Prettus\Repository\Generators\Commands
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
class PresenterCommand extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* The name of command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'make:presenter';
|
||||
|
||||
/**
|
||||
* The description of command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a new presenter.';
|
||||
|
||||
/**
|
||||
* The type of class being generated.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $type = 'Presenter';
|
||||
|
||||
/**
|
||||
* Execute the command.
|
||||
*
|
||||
* @see fire()
|
||||
* @return void
|
||||
*/
|
||||
public function handle(){
|
||||
$this->laravel->call([$this, 'fire'], func_get_args());
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
|
||||
try {
|
||||
(new PresenterGenerator([
|
||||
'name' => $this->argument('name'),
|
||||
'force' => $this->option('force'),
|
||||
]))->run();
|
||||
$this->info("Presenter created successfully.");
|
||||
|
||||
if (!\File::exists(app()->path() . '/Transformers/' . $this->argument('name') . 'Transformer.php')) {
|
||||
if ($this->confirm('Would you like to create a Transformer? [y|N]')) {
|
||||
(new TransformerGenerator([
|
||||
'name' => $this->argument('name'),
|
||||
'force' => $this->option('force'),
|
||||
]))->run();
|
||||
$this->info("Transformer created successfully.");
|
||||
}
|
||||
}
|
||||
} catch (FileAlreadyExistsException $e) {
|
||||
$this->error($this->type . ' already exists!');
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The array of command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getArguments()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'name',
|
||||
InputArgument::REQUIRED,
|
||||
'The name of model for which the presenter is being generated.',
|
||||
null
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The array of command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getOptions()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'force',
|
||||
'f',
|
||||
InputOption::VALUE_NONE,
|
||||
'Force the creation if file already exists.',
|
||||
null
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
191
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Commands/RepositoryCommand.php
vendored
Normal file
191
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Commands/RepositoryCommand.php
vendored
Normal file
@@ -0,0 +1,191 @@
|
||||
<?php
|
||||
namespace Prettus\Repository\Generators\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Str;
|
||||
use Prettus\Repository\Generators\FileAlreadyExistsException;
|
||||
use Prettus\Repository\Generators\MigrationGenerator;
|
||||
use Prettus\Repository\Generators\ModelGenerator;
|
||||
use Prettus\Repository\Generators\RepositoryEloquentGenerator;
|
||||
use Prettus\Repository\Generators\RepositoryInterfaceGenerator;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
/**
|
||||
* Class RepositoryCommand
|
||||
* @package Prettus\Repository\Generators\Commands
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
class RepositoryCommand extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* The name of command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'make:repository';
|
||||
|
||||
/**
|
||||
* The description of command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a new repository.';
|
||||
|
||||
/**
|
||||
* The type of class being generated.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $type = 'Repository';
|
||||
|
||||
/**
|
||||
* @var Collection
|
||||
*/
|
||||
protected $generators = null;
|
||||
|
||||
|
||||
/**
|
||||
* Execute the command.
|
||||
*
|
||||
* @see fire()
|
||||
* @return void
|
||||
*/
|
||||
public function handle(){
|
||||
$this->laravel->call([$this, 'fire'], func_get_args());
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
$this->generators = new Collection();
|
||||
|
||||
$migrationGenerator = new MigrationGenerator([
|
||||
'name' => 'create_' . Str::snake(Str::plural($this->argument('name'))) . '_table',
|
||||
'fields' => $this->option('fillable'),
|
||||
'force' => $this->option('force'),
|
||||
]);
|
||||
|
||||
if (!$this->option('skip-migration')) {
|
||||
$this->generators->push($migrationGenerator);
|
||||
}
|
||||
|
||||
$modelGenerator = new ModelGenerator([
|
||||
'name' => $this->argument('name'),
|
||||
'fillable' => $this->option('fillable'),
|
||||
'force' => $this->option('force')
|
||||
]);
|
||||
|
||||
if (!$this->option('skip-model')) {
|
||||
$this->generators->push($modelGenerator);
|
||||
}
|
||||
|
||||
$this->generators->push(new RepositoryInterfaceGenerator([
|
||||
'name' => $this->argument('name'),
|
||||
'force' => $this->option('force'),
|
||||
]));
|
||||
|
||||
foreach ($this->generators as $generator) {
|
||||
$generator->run();
|
||||
}
|
||||
|
||||
$model = $modelGenerator->getRootNamespace() . '\\' . $modelGenerator->getName();
|
||||
$model = str_replace([
|
||||
"\\",
|
||||
'/'
|
||||
], '\\', $model);
|
||||
|
||||
try {
|
||||
(new RepositoryEloquentGenerator([
|
||||
'name' => $this->argument('name'),
|
||||
'rules' => $this->option('rules'),
|
||||
'validator' => $this->option('validator'),
|
||||
'force' => $this->option('force'),
|
||||
'model' => $model
|
||||
]))->run();
|
||||
$this->info("Repository created successfully.");
|
||||
} catch (FileAlreadyExistsException $e) {
|
||||
$this->error($this->type . ' already exists!');
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The array of command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getArguments()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'name',
|
||||
InputArgument::REQUIRED,
|
||||
'The name of class being generated.',
|
||||
null
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The array of command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getOptions()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'fillable',
|
||||
null,
|
||||
InputOption::VALUE_OPTIONAL,
|
||||
'The fillable attributes.',
|
||||
null
|
||||
],
|
||||
[
|
||||
'rules',
|
||||
null,
|
||||
InputOption::VALUE_OPTIONAL,
|
||||
'The rules of validation attributes.',
|
||||
null
|
||||
],
|
||||
[
|
||||
'validator',
|
||||
null,
|
||||
InputOption::VALUE_OPTIONAL,
|
||||
'Adds validator reference to the repository.',
|
||||
null
|
||||
],
|
||||
[
|
||||
'force',
|
||||
'f',
|
||||
InputOption::VALUE_NONE,
|
||||
'Force the creation if file already exists.',
|
||||
null
|
||||
],
|
||||
[
|
||||
'skip-migration',
|
||||
null,
|
||||
InputOption::VALUE_NONE,
|
||||
'Skip the creation of a migration file.',
|
||||
null,
|
||||
],
|
||||
[
|
||||
'skip-model',
|
||||
null,
|
||||
InputOption::VALUE_NONE,
|
||||
'Skip the creation of a model.',
|
||||
null,
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
105
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Commands/TransformerCommand.php
vendored
Normal file
105
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Commands/TransformerCommand.php
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
namespace Prettus\Repository\Generators\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Collection;
|
||||
use Prettus\Repository\Generators\FileAlreadyExistsException;
|
||||
use Prettus\Repository\Generators\TransformerGenerator;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
/**
|
||||
* Class TransformerCommand
|
||||
* @package Prettus\Repository\Generators\Commands
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
class TransformerCommand extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* The name of command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'make:transformer';
|
||||
|
||||
/**
|
||||
* The description of command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a new transformer.';
|
||||
|
||||
/**
|
||||
* The type of class being generated.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $type = 'Transformer';
|
||||
|
||||
/**
|
||||
* Execute the command.
|
||||
*
|
||||
* @see fire()
|
||||
* @return void
|
||||
*/
|
||||
public function handle(){
|
||||
$this->laravel->call([$this, 'fire'], func_get_args());
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
try {
|
||||
(new TransformerGenerator([
|
||||
'name' => $this->argument('name'),
|
||||
'force' => $this->option('force'),
|
||||
]))->run();
|
||||
$this->info("Transformer created successfully.");
|
||||
} catch (FileAlreadyExistsException $e) {
|
||||
$this->error($this->type . ' already exists!');
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The array of command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getArguments()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'name',
|
||||
InputArgument::REQUIRED,
|
||||
'The name of model for which the transformer is being generated.',
|
||||
null
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* The array of command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getOptions()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'force',
|
||||
'f',
|
||||
InputOption::VALUE_NONE,
|
||||
'Force the creation if file already exists.',
|
||||
null
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
114
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Commands/ValidatorCommand.php
vendored
Normal file
114
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Commands/ValidatorCommand.php
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
namespace Prettus\Repository\Generators\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Collection;
|
||||
use Prettus\Repository\Generators\FileAlreadyExistsException;
|
||||
use Prettus\Repository\Generators\ValidatorGenerator;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
/**
|
||||
* Class ValidatorCommand
|
||||
* @package Prettus\Repository\Generators\Commands
|
||||
*/
|
||||
class ValidatorCommand extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* The name of command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'make:validator';
|
||||
|
||||
/**
|
||||
* The description of command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a new validator.';
|
||||
|
||||
/**
|
||||
* The type of class being generated.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $type = 'Validator';
|
||||
|
||||
|
||||
/**
|
||||
* Execute the command.
|
||||
*
|
||||
* @see fire()
|
||||
* @return void
|
||||
*/
|
||||
public function handle(){
|
||||
$this->laravel->call([$this, 'fire'], func_get_args());
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
try {
|
||||
(new ValidatorGenerator([
|
||||
'name' => $this->argument('name'),
|
||||
'rules' => $this->option('rules'),
|
||||
'force' => $this->option('force'),
|
||||
]))->run();
|
||||
$this->info("Validator created successfully.");
|
||||
} catch (FileAlreadyExistsException $e) {
|
||||
$this->error($this->type . ' already exists!');
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The array of command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getArguments()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'name',
|
||||
InputArgument::REQUIRED,
|
||||
'The name of model for which the validator is being generated.',
|
||||
null
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The array of command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getOptions()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'rules',
|
||||
null,
|
||||
InputOption::VALUE_OPTIONAL,
|
||||
'The rules of validation attributes.',
|
||||
null
|
||||
],
|
||||
[
|
||||
'force',
|
||||
'f',
|
||||
InputOption::VALUE_NONE,
|
||||
'Force the creation if file already exists.',
|
||||
null
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
149
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/ControllerGenerator.php
vendored
Normal file
149
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/ControllerGenerator.php
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
namespace Prettus\Repository\Generators;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Class ControllerGenerator
|
||||
* @package Prettus\Repository\Generators
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
class ControllerGenerator extends Generator
|
||||
{
|
||||
|
||||
/**
|
||||
* Get stub name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $stub = 'controller/controller';
|
||||
|
||||
/**
|
||||
* Get root namespace.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRootNamespace()
|
||||
{
|
||||
return str_replace('/', '\\', parent::getRootNamespace() . parent::getConfigGeneratorClassPath($this->getPathConfigNode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get generator path config node.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPathConfigNode()
|
||||
{
|
||||
return 'controllers';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get destination path for generated file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPath()
|
||||
{
|
||||
return $this->getBasePath() . '/' . parent::getConfigGeneratorClassPath($this->getPathConfigNode(), true) . '/' . $this->getControllerName() . 'Controller.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get base path of destination file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBasePath()
|
||||
{
|
||||
return config('repository.generator.basePath', app()->path());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets controller name based on model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getControllerName()
|
||||
{
|
||||
|
||||
return ucfirst($this->getPluralName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets plural name based on model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPluralName()
|
||||
{
|
||||
|
||||
return Str::plural(lcfirst(ucwords($this->getClass())));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get array replacements.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getReplacements()
|
||||
{
|
||||
|
||||
return array_merge(parent::getReplacements(), [
|
||||
'controller' => $this->getControllerName(),
|
||||
'plural' => $this->getPluralName(),
|
||||
'singular' => $this->getSingularName(),
|
||||
'validator' => $this->getValidator(),
|
||||
'repository' => $this->getRepository(),
|
||||
'appname' => $this->getAppNamespace(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets singular name based on model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSingularName()
|
||||
{
|
||||
return Str::singular(lcfirst(ucwords($this->getClass())));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets validator full class name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getValidator()
|
||||
{
|
||||
$validatorGenerator = new ValidatorGenerator([
|
||||
'name' => $this->name,
|
||||
]);
|
||||
|
||||
$validator = $validatorGenerator->getRootNamespace() . '\\' . $validatorGenerator->getName();
|
||||
|
||||
return 'use ' . str_replace([
|
||||
"\\",
|
||||
'/'
|
||||
], '\\', $validator) . 'Validator;';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets repository full class name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRepository()
|
||||
{
|
||||
$repositoryGenerator = new RepositoryInterfaceGenerator([
|
||||
'name' => $this->name,
|
||||
]);
|
||||
|
||||
$repository = $repositoryGenerator->getRootNamespace() . '\\' . $repositoryGenerator->getName();
|
||||
|
||||
return 'use ' . str_replace([
|
||||
"\\",
|
||||
'/'
|
||||
], '\\', $repository) . 'Repository;';
|
||||
}
|
||||
}
|
||||
57
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/CriteriaGenerator.php
vendored
Normal file
57
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/CriteriaGenerator.php
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace Prettus\Repository\Generators;
|
||||
|
||||
/**
|
||||
* Class CriteriaGenerator
|
||||
* @package Prettus\Repository\Generators
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
class CriteriaGenerator extends Generator
|
||||
{
|
||||
/**
|
||||
* Get stub name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $stub = 'criteria/criteria';
|
||||
|
||||
/**
|
||||
* Get root namespace.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRootNamespace()
|
||||
{
|
||||
return parent::getRootNamespace() . parent::getConfigGeneratorClassPath($this->getPathConfigNode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get generator path config node.
|
||||
* @return string
|
||||
*/
|
||||
public function getPathConfigNode()
|
||||
{
|
||||
return 'criteria';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get destination path for generated file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPath()
|
||||
{
|
||||
return $this->getBasePath() . '/' . parent::getConfigGeneratorClassPath($this->getPathConfigNode(), true) . '/' . $this->getName() . 'Criteria.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get base path of destination file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBasePath()
|
||||
{
|
||||
return config('repository.generator.basePath', app()->path());
|
||||
}
|
||||
}
|
||||
13
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/FileAlreadyExistsException.php
vendored
Normal file
13
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/FileAlreadyExistsException.php
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
namespace Prettus\Repository\Generators;
|
||||
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Class FileAlreadyExistsException
|
||||
* @package Prettus\Repository\Generators
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
class FileAlreadyExistsException extends Exception
|
||||
{
|
||||
}
|
||||
368
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Generator.php
vendored
Normal file
368
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Generator.php
vendored
Normal file
@@ -0,0 +1,368 @@
|
||||
<?php
|
||||
|
||||
namespace Prettus\Repository\Generators;
|
||||
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Class Generator
|
||||
* @package Prettus\Repository\Generators
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
abstract class Generator
|
||||
{
|
||||
|
||||
/**
|
||||
* The filesystem instance.
|
||||
*
|
||||
* @var \Illuminate\Filesystem\Filesystem
|
||||
*/
|
||||
protected $filesystem;
|
||||
|
||||
/**
|
||||
* The array of options.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $options;
|
||||
|
||||
/**
|
||||
* The shortname of stub.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $stub;
|
||||
|
||||
|
||||
/**
|
||||
* Create new instance of this class.
|
||||
*
|
||||
* @param array $options
|
||||
*/
|
||||
public function __construct(array $options = [])
|
||||
{
|
||||
$this->filesystem = new Filesystem;
|
||||
$this->options = $options;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the filesystem instance.
|
||||
*
|
||||
* @return \Illuminate\Filesystem\Filesystem
|
||||
*/
|
||||
public function getFilesystem()
|
||||
{
|
||||
return $this->filesystem;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the filesystem instance.
|
||||
*
|
||||
* @param \Illuminate\Filesystem\Filesystem $filesystem
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setFilesystem(Filesystem $filesystem)
|
||||
{
|
||||
$this->filesystem = $filesystem;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get stub template for generated file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getStub()
|
||||
{
|
||||
$path = config('repository.generator.stubsOverridePath', __DIR__);
|
||||
|
||||
if(!file_exists($path . '/Stubs/' . $this->stub . '.stub')){
|
||||
$path = __DIR__;
|
||||
}
|
||||
|
||||
return (new Stub($path . '/Stubs/' . $this->stub . '.stub', $this->getReplacements()))->render();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get template replacements.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getReplacements()
|
||||
{
|
||||
return [
|
||||
'class' => $this->getClass(),
|
||||
'namespace' => $this->getNamespace(),
|
||||
'root_namespace' => $this->getRootNamespace()
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get base path of destination file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBasePath()
|
||||
{
|
||||
return base_path();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get destination path for generated file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPath()
|
||||
{
|
||||
return $this->getBasePath() . '/' . $this->getName() . '.php';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get name input.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
$name = $this->name;
|
||||
if (Str::contains($this->name, '\\')) {
|
||||
$name = str_replace('\\', '/', $this->name);
|
||||
}
|
||||
if (Str::contains($this->name, '/')) {
|
||||
$name = str_replace('/', '/', $this->name);
|
||||
}
|
||||
|
||||
return Str::studly(str_replace(' ', '/', ucwords(str_replace('/', ' ', $name))));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get application namespace
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAppNamespace()
|
||||
{
|
||||
return \Illuminate\Container\Container::getInstance()->getNamespace();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get class name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getClass()
|
||||
{
|
||||
return Str::studly(class_basename($this->getName()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get paths of namespace.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getSegments()
|
||||
{
|
||||
return explode('/', $this->getName());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get root namespace.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRootNamespace()
|
||||
{
|
||||
return config('repository.generator.rootNamespace', $this->getAppNamespace());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get class-specific output paths.
|
||||
*
|
||||
* @param $class
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getConfigGeneratorClassPath($class, $directoryPath = false)
|
||||
{
|
||||
switch ($class) {
|
||||
case ('models' === $class):
|
||||
$path = config('repository.generator.paths.models', 'Entities');
|
||||
break;
|
||||
case ('repositories' === $class):
|
||||
$path = config('repository.generator.paths.repositories', 'Repositories');
|
||||
break;
|
||||
case ('interfaces' === $class):
|
||||
$path = config('repository.generator.paths.interfaces', 'Repositories');
|
||||
break;
|
||||
case ('presenters' === $class):
|
||||
$path = config('repository.generator.paths.presenters', 'Presenters');
|
||||
break;
|
||||
case ('transformers' === $class):
|
||||
$path = config('repository.generator.paths.transformers', 'Transformers');
|
||||
break;
|
||||
case ('validators' === $class):
|
||||
$path = config('repository.generator.paths.validators', 'Validators');
|
||||
break;
|
||||
case ('controllers' === $class):
|
||||
$path = config('repository.generator.paths.controllers', 'Http\Controllers');
|
||||
break;
|
||||
case ('provider' === $class):
|
||||
$path = config('repository.generator.paths.provider', 'RepositoryServiceProvider');
|
||||
break;
|
||||
case ('criteria' === $class):
|
||||
$path = config('repository.generator.paths.criteria', 'Criteria');
|
||||
break;
|
||||
default:
|
||||
$path = '';
|
||||
}
|
||||
|
||||
if ($directoryPath) {
|
||||
$path = str_replace('\\', '/', $path);
|
||||
} else {
|
||||
$path = str_replace('/', '\\', $path);
|
||||
}
|
||||
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
|
||||
abstract public function getPathConfigNode();
|
||||
|
||||
|
||||
/**
|
||||
* Get class namespace.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getNamespace()
|
||||
{
|
||||
$segments = $this->getSegments();
|
||||
array_pop($segments);
|
||||
$rootNamespace = $this->getRootNamespace();
|
||||
if ($rootNamespace == false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return 'namespace ' . rtrim($rootNamespace . '\\' . implode('\\', $segments), '\\') . ';';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Setup some hook.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Run the generator.
|
||||
*
|
||||
* @return int
|
||||
* @throws FileAlreadyExistsException
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$this->setUp();
|
||||
if ($this->filesystem->exists($path = $this->getPath()) && !$this->force) {
|
||||
throw new FileAlreadyExistsException($path);
|
||||
}
|
||||
if (!$this->filesystem->isDirectory($dir = dirname($path))) {
|
||||
$this->filesystem->makeDirectory($dir, 0777, true, true);
|
||||
}
|
||||
|
||||
return $this->filesystem->put($path, $this->getStub());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get options.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getOptions()
|
||||
{
|
||||
return $this->options;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determinte whether the given key exist in options array.
|
||||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasOption($key)
|
||||
{
|
||||
return array_key_exists($key, $this->options);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get value from options by given key.
|
||||
*
|
||||
* @param string $key
|
||||
* @param string|null $default
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getOption($key, $default = null)
|
||||
{
|
||||
if (!$this->hasOption($key)) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
return $this->options[$key] ?: $default;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper method for "getOption".
|
||||
*
|
||||
* @param string $key
|
||||
* @param string|null $default
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function option($key, $default = null)
|
||||
{
|
||||
return $this->getOption($key, $default);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle call to __get method.
|
||||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return string|mixed
|
||||
*/
|
||||
public function __get($key)
|
||||
{
|
||||
if (property_exists($this, $key)) {
|
||||
return $this->{$key};
|
||||
}
|
||||
|
||||
return $this->option($key);
|
||||
}
|
||||
}
|
||||
169
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/MigrationGenerator.php
vendored
Normal file
169
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/MigrationGenerator.php
vendored
Normal file
@@ -0,0 +1,169 @@
|
||||
<?php
|
||||
|
||||
namespace Prettus\Repository\Generators;
|
||||
|
||||
use Prettus\Repository\Generators\Migrations\NameParser;
|
||||
use Prettus\Repository\Generators\Migrations\SchemaParser;
|
||||
use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
|
||||
|
||||
/**
|
||||
* Class MigrationGenerator
|
||||
* @package Prettus\Repository\Generators
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
class MigrationGenerator extends Generator
|
||||
{
|
||||
|
||||
/**
|
||||
* Get stub name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $stub = 'migration/plain';
|
||||
|
||||
|
||||
/**
|
||||
* Get base path of destination file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBasePath()
|
||||
{
|
||||
return base_path() . '/database/migrations/';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get destination path for generated file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPath()
|
||||
{
|
||||
return $this->getBasePath() . $this->getFileName() . '.php';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get generator path config node.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPathConfigNode()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get root namespace.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRootNamespace()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get migration name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMigrationName()
|
||||
{
|
||||
return strtolower($this->name);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get file name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFileName()
|
||||
{
|
||||
return date('Y_m_d_His_') . $this->getMigrationName();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get schema parser.
|
||||
*
|
||||
* @return SchemaParser
|
||||
*/
|
||||
public function getSchemaParser()
|
||||
{
|
||||
return new SchemaParser($this->fields);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get name parser.
|
||||
*
|
||||
* @return NameParser
|
||||
*/
|
||||
public function getNameParser()
|
||||
{
|
||||
return new NameParser($this->name);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get stub templates.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getStub()
|
||||
{
|
||||
$parser = $this->getNameParser();
|
||||
|
||||
$action = $parser->getAction();
|
||||
switch ($action) {
|
||||
case 'add':
|
||||
case 'append':
|
||||
case 'update':
|
||||
case 'insert':
|
||||
$file = 'change';
|
||||
$replacements = [
|
||||
'class' => $this->getClass(),
|
||||
'table' => $parser->getTable(),
|
||||
'fields_up' => $this->getSchemaParser()->up(),
|
||||
'fields_down' => $this->getSchemaParser()->down(),
|
||||
];
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
case 'remove':
|
||||
case 'alter':
|
||||
$file = 'change';
|
||||
$replacements = [
|
||||
'class' => $this->getClass(),
|
||||
'table' => $parser->getTable(),
|
||||
'fields_down' => $this->getSchemaParser()->up(),
|
||||
'fields_up' => $this->getSchemaParser()->down(),
|
||||
];
|
||||
break;
|
||||
default:
|
||||
$file = 'create';
|
||||
$replacements = [
|
||||
'class' => $this->getClass(),
|
||||
'table' => $parser->getTable(),
|
||||
'fields' => $this->getSchemaParser()->up(),
|
||||
];
|
||||
break;
|
||||
}
|
||||
$path = config('repository.generator.stubsOverridePath', __DIR__);
|
||||
|
||||
if (!file_exists($path . "/Stubs/migration/{$file}.stub")) {
|
||||
$path = __DIR__;
|
||||
}
|
||||
|
||||
if (!file_exists($path . "/Stubs/migration/{$file}.stub")) {
|
||||
throw new FileNotFoundException($path . "/Stubs/migration/{$file}.stub");
|
||||
}
|
||||
|
||||
return Stub::create($path . "/Stubs/migration/{$file}.stub", $replacements);
|
||||
}
|
||||
}
|
||||
211
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Migrations/NameParser.php
vendored
Normal file
211
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Migrations/NameParser.php
vendored
Normal file
@@ -0,0 +1,211 @@
|
||||
<?php
|
||||
namespace Prettus\Repository\Generators\Migrations;
|
||||
|
||||
/**
|
||||
* Class NameParser
|
||||
* @package Prettus\Repository\Generators\Migrations
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
class NameParser
|
||||
{
|
||||
/**
|
||||
* The migration name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name;
|
||||
/**
|
||||
* The array data.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $data = [];
|
||||
/**
|
||||
* The available schema actions.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $actions = [
|
||||
'create' => [
|
||||
'create',
|
||||
'make'
|
||||
],
|
||||
'delete' => [
|
||||
'delete',
|
||||
'remove'
|
||||
],
|
||||
'add' => [
|
||||
'add',
|
||||
'update',
|
||||
'append',
|
||||
'insert'
|
||||
],
|
||||
'drop' => [
|
||||
'destroy',
|
||||
'drop'
|
||||
]
|
||||
];
|
||||
|
||||
/**
|
||||
* The constructor.
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->data = $this->fetchData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the migration name to an array data.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function fetchData()
|
||||
{
|
||||
return explode('_', $this->name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get original migration name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getOriginalName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get table name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTable()
|
||||
{
|
||||
return $this->getTableName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the table will be used.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTableName()
|
||||
{
|
||||
$matches = array_reverse($this->getMatches());
|
||||
|
||||
return array_shift($matches);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get matches data from regex.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getMatches()
|
||||
{
|
||||
preg_match($this->getPattern(), $this->name, $matches);
|
||||
|
||||
return $matches;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name pattern.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPattern()
|
||||
{
|
||||
switch ($action = $this->getAction()) {
|
||||
case 'add':
|
||||
case 'append':
|
||||
case 'update':
|
||||
case 'insert':
|
||||
return "/{$action}_(.*)_to_(.*)_table/";
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
case 'remove':
|
||||
case 'alter':
|
||||
return "/{$action}_(.*)_from_(.*)_table/";
|
||||
break;
|
||||
default:
|
||||
return "/{$action}_(.*)_table/";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get schema type or action.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAction()
|
||||
{
|
||||
return head($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array data.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the given type is same with the current schema action or type.
|
||||
*
|
||||
* @param $type
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is($type)
|
||||
{
|
||||
return $type == $this->getAction();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the current schema action is a adding action.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isAdd()
|
||||
{
|
||||
return in_array($this->getAction(), $this->actions['add']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the current schema action is a deleting action.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isDelete()
|
||||
{
|
||||
return in_array($this->getAction(), $this->actions['delete']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the current schema action is a creating action.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isCreate()
|
||||
{
|
||||
return in_array($this->getAction(), $this->actions['create']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the current schema action is a dropping action.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isDrop()
|
||||
{
|
||||
return in_array($this->getAction(), $this->actions['drop']);
|
||||
}
|
||||
}
|
||||
106
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Migrations/RulesParser.php
vendored
Normal file
106
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Migrations/RulesParser.php
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
namespace Prettus\Repository\Generators\Migrations;
|
||||
|
||||
use Illuminate\Contracts\Support\Arrayable;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
/**
|
||||
* Class RulesParser
|
||||
* @package Prettus\Repository\Generators\Migrations
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
class RulesParser implements Arrayable
|
||||
{
|
||||
|
||||
/**
|
||||
* The set of rules.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $rules;
|
||||
|
||||
|
||||
/**
|
||||
* Create new instance.
|
||||
*
|
||||
* @param string|null $rules
|
||||
*/
|
||||
public function __construct($rules = null)
|
||||
{
|
||||
$this->rules = $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert string migration to array.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
return $this->parse($this->rules);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a string to array of formatted rules.
|
||||
*
|
||||
* @param string $rules
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function parse($rules)
|
||||
{
|
||||
$this->rules = $rules;
|
||||
$parsed = [];
|
||||
foreach ($this->getRules() as $rulesArray) {
|
||||
$column = $this->getColumn($rulesArray);
|
||||
$attributes = $this->getAttributes($column, $rulesArray);
|
||||
$parsed[$column] = $attributes;
|
||||
}
|
||||
|
||||
return $parsed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get array of rules.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getRules()
|
||||
{
|
||||
if (is_null($this->rules)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return explode(',', str_replace(' ', '', $this->rules));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get column name from rules.
|
||||
*
|
||||
* @param string $rules
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getColumn($rules)
|
||||
{
|
||||
return Arr::first(explode('=>', $rules), function ($key, $value) {
|
||||
return $value;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get column attributes.
|
||||
*
|
||||
* @param string $column
|
||||
* @param string $rules
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAttributes($column, $rules)
|
||||
{
|
||||
|
||||
return str_replace($column . '=>', '', $rules);
|
||||
}
|
||||
|
||||
}
|
||||
237
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Migrations/SchemaParser.php
vendored
Normal file
237
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Migrations/SchemaParser.php
vendored
Normal file
@@ -0,0 +1,237 @@
|
||||
<?php
|
||||
namespace Prettus\Repository\Generators\Migrations;
|
||||
|
||||
use Illuminate\Contracts\Support\Arrayable;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Class SchemaParser
|
||||
* @package Prettus\Repository\Generators\Migrations
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
class SchemaParser implements Arrayable
|
||||
{
|
||||
/**
|
||||
* The array of custom attributes.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $customAttributes = [
|
||||
'remember_token' => 'rememberToken()',
|
||||
'soft_delete' => 'softDeletes()',
|
||||
];
|
||||
/**
|
||||
* The migration schema.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $schema;
|
||||
|
||||
/**
|
||||
* Create new instance.
|
||||
*
|
||||
* @param string|null $schema
|
||||
*/
|
||||
public function __construct($schema = null)
|
||||
{
|
||||
$this->schema = $schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render up migration fields.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
return $this->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the migration to formatted script.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$results = '';
|
||||
foreach ($this->toArray() as $column => $attributes) {
|
||||
$results .= $this->createField($column, $attributes);
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert string migration to array.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
return $this->parse($this->schema);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a string to array of formatted schema.
|
||||
*
|
||||
* @param string $schema
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function parse($schema)
|
||||
{
|
||||
$this->schema = $schema;
|
||||
$parsed = [];
|
||||
foreach ($this->getSchemas() as $schemaArray) {
|
||||
$column = $this->getColumn($schemaArray);
|
||||
$attributes = $this->getAttributes($column, $schemaArray);
|
||||
$parsed[$column] = $attributes;
|
||||
}
|
||||
|
||||
return $parsed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get array of schema.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getSchemas()
|
||||
{
|
||||
if (is_null($this->schema)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return explode(',', str_replace(' ', '', $this->schema));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get column name from schema.
|
||||
*
|
||||
* @param string $schema
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getColumn($schema)
|
||||
{
|
||||
return Arr::first(explode(':', $schema), function ($key, $value) {
|
||||
return $value;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get column attributes.
|
||||
*
|
||||
* @param string $column
|
||||
* @param string $schema
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAttributes($column, $schema)
|
||||
{
|
||||
$fields = str_replace($column . ':', '', $schema);
|
||||
|
||||
return $this->hasCustomAttribute($column) ? $this->getCustomAttribute($column) : explode(':', $fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determinte whether the given column is exist in customAttributes array.
|
||||
*
|
||||
* @param string $column
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasCustomAttribute($column)
|
||||
{
|
||||
return array_key_exists($column, $this->customAttributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom attributes value.
|
||||
*
|
||||
* @param string $column
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getCustomAttribute($column)
|
||||
{
|
||||
return (array)$this->customAttributes[$column];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create field.
|
||||
*
|
||||
* @param string $column
|
||||
* @param array $attributes
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function createField($column, $attributes, $type = 'add')
|
||||
{
|
||||
$results = "\t\t\t" . '$table';
|
||||
foreach ($attributes as $key => $field) {
|
||||
$results .= $this->{"{$type}Column"}($key, $field, $column);
|
||||
}
|
||||
|
||||
return $results .= ';' . PHP_EOL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render down migration fields.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
$results = '';
|
||||
foreach ($this->toArray() as $column => $attributes) {
|
||||
$results .= $this->createField($column, $attributes, 'remove');
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format field to script.
|
||||
*
|
||||
* @param int $key
|
||||
* @param string $field
|
||||
* @param string $column
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function addColumn($key, $field, $column)
|
||||
{
|
||||
if ($this->hasCustomAttribute($column)) {
|
||||
return '->' . $field;
|
||||
}
|
||||
if ($key == 0) {
|
||||
return '->' . $field . "('" . $column . "')";
|
||||
}
|
||||
if (Str::contains($field, '(')) {
|
||||
return '->' . $field;
|
||||
}
|
||||
|
||||
return '->' . $field . '()';
|
||||
}
|
||||
|
||||
/**
|
||||
* Format field to script.
|
||||
*
|
||||
* @param int $key
|
||||
* @param string $field
|
||||
* @param string $column
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function removeColumn($key, $field, $column)
|
||||
{
|
||||
if ($this->hasCustomAttribute($column)) {
|
||||
return '->' . $field;
|
||||
}
|
||||
|
||||
return '->dropColumn(' . "'" . $column . "')";
|
||||
}
|
||||
}
|
||||
103
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/ModelGenerator.php
vendored
Normal file
103
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/ModelGenerator.php
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace Prettus\Repository\Generators;
|
||||
|
||||
use Prettus\Repository\Generators\Migrations\SchemaParser;
|
||||
|
||||
/**
|
||||
* Class ModelGenerator
|
||||
* @package Prettus\Repository\Generators
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
class ModelGenerator extends Generator
|
||||
{
|
||||
|
||||
/**
|
||||
* Get stub name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $stub = 'model';
|
||||
|
||||
/**
|
||||
* Get root namespace.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRootNamespace()
|
||||
{
|
||||
return parent::getRootNamespace() . parent::getConfigGeneratorClassPath($this->getPathConfigNode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get generator path config node.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPathConfigNode()
|
||||
{
|
||||
return 'models';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get destination path for generated file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPath()
|
||||
{
|
||||
return $this->getBasePath() . '/' . parent::getConfigGeneratorClassPath($this->getPathConfigNode(), true) . '/' . $this->getName() . '.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get base path of destination file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
||||
public function getBasePath()
|
||||
{
|
||||
return config('repository.generator.basePath', app()->path());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get array replacements.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getReplacements()
|
||||
{
|
||||
return array_merge(parent::getReplacements(), [
|
||||
'fillable' => $this->getFillable()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fillable attributes.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFillable()
|
||||
{
|
||||
if (!$this->fillable) {
|
||||
return '[]';
|
||||
}
|
||||
$results = '[' . PHP_EOL;
|
||||
|
||||
foreach ($this->getSchemaParser()->toArray() as $column => $value) {
|
||||
$results .= "\t\t'{$column}'," . PHP_EOL;
|
||||
}
|
||||
|
||||
return $results . "\t" . ']';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get schema parser.
|
||||
*
|
||||
* @return SchemaParser
|
||||
*/
|
||||
public function getSchemaParser()
|
||||
{
|
||||
return new SchemaParser($this->fillable);
|
||||
}
|
||||
}
|
||||
79
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/PresenterGenerator.php
vendored
Normal file
79
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/PresenterGenerator.php
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
namespace Prettus\Repository\Generators;
|
||||
|
||||
/**
|
||||
* Class PresenterGenerator
|
||||
* @package Prettus\Repository\Generators
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
class PresenterGenerator extends Generator
|
||||
{
|
||||
/**
|
||||
* Get stub name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $stub = 'presenter/presenter';
|
||||
|
||||
/**
|
||||
* Get root namespace.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRootNamespace()
|
||||
{
|
||||
return parent::getRootNamespace() . parent::getConfigGeneratorClassPath($this->getPathConfigNode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get generator path config node.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPathConfigNode()
|
||||
{
|
||||
return 'presenters';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get array replacements.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getReplacements()
|
||||
{
|
||||
$transformerGenerator = new TransformerGenerator([
|
||||
'name' => $this->name
|
||||
]);
|
||||
$transformer = $transformerGenerator->getRootNamespace() . '\\' . $transformerGenerator->getName() . 'Transformer';
|
||||
$transformer = str_replace([
|
||||
"\\",
|
||||
'/'
|
||||
], '\\', $transformer);
|
||||
echo $transformer;
|
||||
|
||||
return array_merge(parent::getReplacements(), [
|
||||
'transformer' => $transformer
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get destination path for generated file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPath()
|
||||
{
|
||||
return $this->getBasePath() . '/' . parent::getConfigGeneratorClassPath($this->getPathConfigNode(), true) . '/' . $this->getName() . 'Presenter.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get base path of destination file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBasePath()
|
||||
{
|
||||
return config('repository.generator.basePath', app()->path());
|
||||
}
|
||||
}
|
||||
149
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/RepositoryEloquentGenerator.php
vendored
Normal file
149
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/RepositoryEloquentGenerator.php
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
namespace Prettus\Repository\Generators;
|
||||
|
||||
use Prettus\Repository\Generators\Migrations\SchemaParser;
|
||||
|
||||
/**
|
||||
* Class RepositoryEloquentGenerator
|
||||
* @package Prettus\Repository\Generators
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
class RepositoryEloquentGenerator extends Generator
|
||||
{
|
||||
|
||||
/**
|
||||
* Get stub name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $stub = 'repository/eloquent';
|
||||
|
||||
/**
|
||||
* Get root namespace.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRootNamespace()
|
||||
{
|
||||
return parent::getRootNamespace() . parent::getConfigGeneratorClassPath($this->getPathConfigNode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get generator path config node.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPathConfigNode()
|
||||
{
|
||||
return 'repositories';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get destination path for generated file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPath()
|
||||
{
|
||||
return $this->getBasePath() . '/' . parent::getConfigGeneratorClassPath($this->getPathConfigNode(), true) . '/' . $this->getName() . 'RepositoryEloquent.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get base path of destination file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBasePath()
|
||||
{
|
||||
return config('repository.generator.basePath', app()->path());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get array replacements.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getReplacements()
|
||||
{
|
||||
$repository = parent::getRootNamespace() . parent::getConfigGeneratorClassPath('interfaces') . '\\' . $this->name . 'Repository;';
|
||||
$repository = str_replace([
|
||||
"\\",
|
||||
'/'
|
||||
], '\\', $repository);
|
||||
|
||||
return array_merge(parent::getReplacements(), [
|
||||
'fillable' => $this->getFillable(),
|
||||
'use_validator' => $this->getValidatorUse(),
|
||||
'validator' => $this->getValidatorMethod(),
|
||||
'repository' => $repository,
|
||||
'model' => isset($this->options['model']) ? $this->options['model'] : ''
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fillable attributes.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFillable()
|
||||
{
|
||||
if (!$this->fillable) {
|
||||
return '[]';
|
||||
}
|
||||
$results = '[' . PHP_EOL;
|
||||
|
||||
foreach ($this->getSchemaParser()->toArray() as $column => $value) {
|
||||
$results .= "\t\t'{$column}'," . PHP_EOL;
|
||||
}
|
||||
|
||||
return $results . "\t" . ']';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get schema parser.
|
||||
*
|
||||
* @return SchemaParser
|
||||
*/
|
||||
public function getSchemaParser()
|
||||
{
|
||||
return new SchemaParser($this->fillable);
|
||||
}
|
||||
|
||||
public function getValidatorUse()
|
||||
{
|
||||
$validator = $this->getValidator();
|
||||
|
||||
return "use {$validator};";
|
||||
}
|
||||
|
||||
|
||||
public function getValidator()
|
||||
{
|
||||
$validatorGenerator = new ValidatorGenerator([
|
||||
'name' => $this->name,
|
||||
'rules' => $this->rules,
|
||||
'force' => $this->force,
|
||||
]);
|
||||
|
||||
$validator = $validatorGenerator->getRootNamespace() . '\\' . $validatorGenerator->getName();
|
||||
|
||||
return str_replace([
|
||||
"\\",
|
||||
'/'
|
||||
], '\\', $validator) . 'Validator';
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function getValidatorMethod()
|
||||
{
|
||||
if ($this->validator != 'yes') {
|
||||
return '';
|
||||
}
|
||||
|
||||
$class = $this->getClass();
|
||||
|
||||
return '/**' . PHP_EOL . ' * Specify Validator class name' . PHP_EOL . ' *' . PHP_EOL . ' * @return mixed' . PHP_EOL . ' */' . PHP_EOL . ' public function validator()' . PHP_EOL . ' {' . PHP_EOL . PHP_EOL . ' return ' . $class . 'Validator::class;' . PHP_EOL . ' }' . PHP_EOL;
|
||||
|
||||
}
|
||||
}
|
||||
102
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/RepositoryInterfaceGenerator.php
vendored
Normal file
102
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/RepositoryInterfaceGenerator.php
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace Prettus\Repository\Generators;
|
||||
|
||||
use Prettus\Repository\Generators\Migrations\SchemaParser;
|
||||
|
||||
/**
|
||||
* Class RepositoryInterfaceGenerator
|
||||
* @package Prettus\Repository\Generators
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
class RepositoryInterfaceGenerator extends Generator
|
||||
{
|
||||
|
||||
/**
|
||||
* Get stub name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $stub = 'repository/interface';
|
||||
|
||||
/**
|
||||
* Get root namespace.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRootNamespace()
|
||||
{
|
||||
return parent::getRootNamespace() . parent::getConfigGeneratorClassPath($this->getPathConfigNode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get generator path config node.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPathConfigNode()
|
||||
{
|
||||
return 'interfaces';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get destination path for generated file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPath()
|
||||
{
|
||||
return $this->getBasePath() . '/' . parent::getConfigGeneratorClassPath($this->getPathConfigNode(), true) . '/' . $this->getName() . 'Repository.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get base path of destination file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBasePath()
|
||||
{
|
||||
return config('repository.generator.basePath', app()->path());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get array replacements.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getReplacements()
|
||||
{
|
||||
return array_merge(parent::getReplacements(), [
|
||||
'fillable' => $this->getFillable()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fillable attributes.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFillable()
|
||||
{
|
||||
if (!$this->fillable) {
|
||||
return '[]';
|
||||
}
|
||||
$results = '[' . PHP_EOL;
|
||||
|
||||
foreach ($this->getSchemaParser()->toArray() as $column => $value) {
|
||||
$results .= "\t\t'{$column}'," . PHP_EOL;
|
||||
}
|
||||
|
||||
return $results . "\t" . ']';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get schema parser.
|
||||
*
|
||||
* @return SchemaParser
|
||||
*/
|
||||
public function getSchemaParser()
|
||||
{
|
||||
return new SchemaParser($this->fillable);
|
||||
}
|
||||
}
|
||||
150
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Stub.php
vendored
Normal file
150
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Stub.php
vendored
Normal file
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
namespace Prettus\Repository\Generators;
|
||||
|
||||
/**
|
||||
* Class Stub
|
||||
* @package Prettus\Repository\Generators
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
class Stub
|
||||
{
|
||||
/**
|
||||
* The base path of stub file.
|
||||
*
|
||||
* @var null|string
|
||||
*/
|
||||
protected static $basePath = null;
|
||||
/**
|
||||
* The stub path.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $path;
|
||||
/**
|
||||
* The replacements array.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $replaces = [];
|
||||
|
||||
/**
|
||||
* The contructor.
|
||||
*
|
||||
* @param string $path
|
||||
* @param array $replaces
|
||||
*/
|
||||
public function __construct($path, array $replaces = [])
|
||||
{
|
||||
$this->path = $path;
|
||||
$this->replaces = $replaces;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new self instance.
|
||||
*
|
||||
* @param string $path
|
||||
* @param array $replaces
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function create($path, array $replaces = [])
|
||||
{
|
||||
return new static($path, $replaces);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set base path.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function setBasePath($path)
|
||||
{
|
||||
static::$basePath = $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set replacements array.
|
||||
*
|
||||
* @param array $replaces
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function replace(array $replaces = [])
|
||||
{
|
||||
$this->replaces = $replaces;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get replacements.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getReplaces()
|
||||
{
|
||||
return $this->replaces;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle magic method __toString.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get stub contents.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return $this->getContents();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get stub contents.
|
||||
*
|
||||
* @return mixed|string
|
||||
*/
|
||||
public function getContents()
|
||||
{
|
||||
$contents = file_get_contents($this->getPath());
|
||||
foreach ($this->replaces as $search => $replace) {
|
||||
$contents = str_replace('$' . strtoupper($search) . '$', $replace, $contents);
|
||||
}
|
||||
|
||||
return $contents;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get stub path.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPath()
|
||||
{
|
||||
return static::$basePath . $this->path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set stub path.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setPath($path)
|
||||
{
|
||||
$this->path = $path;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
102
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Stubs/api/controller.stub
vendored
Normal file
102
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Stubs/api/controller.stub
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
$NAMESPACE$
|
||||
|
||||
use $APPNAME$Http\Controllers\Controller;
|
||||
$REPOSITORY$
|
||||
use $APPNAME$Http\Requests\$CLASS$\{
|
||||
IndexRequest,
|
||||
CreateRequest,
|
||||
ShowRequest,
|
||||
UpdateRequest,
|
||||
DestroyRequest,
|
||||
};
|
||||
|
||||
/**
|
||||
* Class $CONTROLLER$Controller.
|
||||
*
|
||||
* @package $NAMESPACE$
|
||||
*/
|
||||
class $CONTROLLER$Controller extends Controller
|
||||
{
|
||||
/**
|
||||
* @var $CLASS$Repository
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* $CONTROLLER$Controller constructor.
|
||||
*
|
||||
* @param $CLASS$Repository $repository
|
||||
*/
|
||||
public function __construct($CLASS$Repository $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index(IndexRequest $request)
|
||||
{
|
||||
$data = $this->repository->all();
|
||||
return $this->respond($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param $CLASS\CreateRequest $request
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(CreateRequest $request)
|
||||
{
|
||||
$data = $this->repository->create($request->all());
|
||||
return $this->respondCreated($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
|
||||
* @param $CLASS\ShowRequest $request
|
||||
* @param int $id
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(ShowRequest $request, $id)
|
||||
{
|
||||
$data = $this->repository->find($id);
|
||||
return $this->respond($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param $CLASS\UpdateRequest $request
|
||||
* @param string $id
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function update(UpdateRequest $request, $id)
|
||||
{
|
||||
$data = $this->repository->update($request->all(), $id);
|
||||
return $this->respond($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param $CLASS\DestroyRequest $request
|
||||
* @param int $id
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(DestroyRequest $request, $id)
|
||||
{
|
||||
$this->repository->delete($id);
|
||||
return $this->respondNoContent();
|
||||
}
|
||||
}
|
||||
35
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Stubs/api/eloquent.stub
vendored
Normal file
35
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Stubs/api/eloquent.stub
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
$NAMESPACE$
|
||||
|
||||
use Prettus\Repository\Eloquent\BaseRepository;
|
||||
use Prettus\Repository\Criteria\RequestCriteria;
|
||||
use $REPOSITORY$
|
||||
use $MODEL$;
|
||||
|
||||
/**
|
||||
* Class $CLASS$RepositoryEloquent.
|
||||
*
|
||||
* @package $NAMESPACE$
|
||||
*/
|
||||
class $CLASS$RepositoryEloquent extends BaseRepository implements $CLASS$Repository
|
||||
{
|
||||
/**
|
||||
* Specify Model class name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function model()
|
||||
{
|
||||
return $CLASS$::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Boot up the repository, pushing criteria
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->pushCriteria(app(RequestCriteria::class));
|
||||
}
|
||||
|
||||
}
|
||||
3
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Stubs/bindings/bindings.stub
vendored
Normal file
3
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Stubs/bindings/bindings.stub
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
$this->app->bind($REPOSITORY$, $ELOQUENT$);
|
||||
$PLACEHOLDER$
|
||||
204
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Stubs/controller/controller.stub
vendored
Normal file
204
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Stubs/controller/controller.stub
vendored
Normal file
@@ -0,0 +1,204 @@
|
||||
<?php
|
||||
|
||||
$NAMESPACE$
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use $APPNAME$Http\Requests;
|
||||
use Prettus\Validator\Contracts\ValidatorInterface;
|
||||
use Prettus\Validator\Exceptions\ValidatorException;
|
||||
use $APPNAME$Http\Requests\$CLASS$CreateRequest;
|
||||
use $APPNAME$Http\Requests\$CLASS$UpdateRequest;
|
||||
$REPOSITORY$
|
||||
$VALIDATOR$
|
||||
|
||||
/**
|
||||
* Class $CONTROLLER$Controller.
|
||||
*
|
||||
* @package $NAMESPACE$
|
||||
*/
|
||||
class $CONTROLLER$Controller extends Controller
|
||||
{
|
||||
/**
|
||||
* @var $CLASS$Repository
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* @var $CLASS$Validator
|
||||
*/
|
||||
protected $validator;
|
||||
|
||||
/**
|
||||
* $CONTROLLER$Controller constructor.
|
||||
*
|
||||
* @param $CLASS$Repository $repository
|
||||
* @param $CLASS$Validator $validator
|
||||
*/
|
||||
public function __construct($CLASS$Repository $repository, $CLASS$Validator $validator)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
$this->validator = $validator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->repository->pushCriteria(app('Prettus\Repository\Criteria\RequestCriteria'));
|
||||
$$PLURAL$ = $this->repository->all();
|
||||
|
||||
if (request()->wantsJson()) {
|
||||
|
||||
return response()->json([
|
||||
'data' => $$PLURAL$,
|
||||
]);
|
||||
}
|
||||
|
||||
return view('$PLURAL$.index', compact('$PLURAL$'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param $CLASS$CreateRequest $request
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*
|
||||
* @throws \Prettus\Validator\Exceptions\ValidatorException
|
||||
*/
|
||||
public function store($CLASS$CreateRequest $request)
|
||||
{
|
||||
try {
|
||||
|
||||
$this->validator->with($request->all())->passesOrFail(ValidatorInterface::RULE_CREATE);
|
||||
|
||||
$$SINGULAR$ = $this->repository->create($request->all());
|
||||
|
||||
$response = [
|
||||
'message' => '$CLASS$ created.',
|
||||
'data' => $$SINGULAR$->toArray(),
|
||||
];
|
||||
|
||||
if ($request->wantsJson()) {
|
||||
|
||||
return response()->json($response);
|
||||
}
|
||||
|
||||
return redirect()->back()->with('message', $response['message']);
|
||||
} catch (ValidatorException $e) {
|
||||
if ($request->wantsJson()) {
|
||||
return response()->json([
|
||||
'error' => true,
|
||||
'message' => $e->getMessageBag()
|
||||
]);
|
||||
}
|
||||
|
||||
return redirect()->back()->withErrors($e->getMessageBag())->withInput();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$$SINGULAR$ = $this->repository->find($id);
|
||||
|
||||
if (request()->wantsJson()) {
|
||||
|
||||
return response()->json([
|
||||
'data' => $$SINGULAR$,
|
||||
]);
|
||||
}
|
||||
|
||||
return view('$PLURAL$.show', compact('$SINGULAR$'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$$SINGULAR$ = $this->repository->find($id);
|
||||
|
||||
return view('$PLURAL$.edit', compact('$SINGULAR$'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param $CLASS$UpdateRequest $request
|
||||
* @param string $id
|
||||
*
|
||||
* @return Response
|
||||
*
|
||||
* @throws \Prettus\Validator\Exceptions\ValidatorException
|
||||
*/
|
||||
public function update($CLASS$UpdateRequest $request, $id)
|
||||
{
|
||||
try {
|
||||
|
||||
$this->validator->with($request->all())->passesOrFail(ValidatorInterface::RULE_UPDATE);
|
||||
|
||||
$$SINGULAR$ = $this->repository->update($request->all(), $id);
|
||||
|
||||
$response = [
|
||||
'message' => '$CLASS$ updated.',
|
||||
'data' => $$SINGULAR$->toArray(),
|
||||
];
|
||||
|
||||
if ($request->wantsJson()) {
|
||||
|
||||
return response()->json($response);
|
||||
}
|
||||
|
||||
return redirect()->back()->with('message', $response['message']);
|
||||
} catch (ValidatorException $e) {
|
||||
|
||||
if ($request->wantsJson()) {
|
||||
|
||||
return response()->json([
|
||||
'error' => true,
|
||||
'message' => $e->getMessageBag()
|
||||
]);
|
||||
}
|
||||
|
||||
return redirect()->back()->withErrors($e->getMessageBag())->withInput();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$deleted = $this->repository->delete($id);
|
||||
|
||||
if (request()->wantsJson()) {
|
||||
|
||||
return response()->json([
|
||||
'message' => '$CLASS$ deleted.',
|
||||
'deleted' => $deleted,
|
||||
]);
|
||||
}
|
||||
|
||||
return redirect()->back()->with('message', '$CLASS$ deleted.');
|
||||
}
|
||||
}
|
||||
27
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Stubs/criteria/criteria.stub
vendored
Normal file
27
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Stubs/criteria/criteria.stub
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
$NAMESPACE$
|
||||
|
||||
use Prettus\Repository\Contracts\CriteriaInterface;
|
||||
use Prettus\Repository\Contracts\RepositoryInterface;
|
||||
|
||||
/**
|
||||
* Class $CLASS$Criteria.
|
||||
*
|
||||
* @package $NAMESPACE$
|
||||
*/
|
||||
class $CLASS$Criteria implements CriteriaInterface
|
||||
{
|
||||
/**
|
||||
* Apply criteria in query repository
|
||||
*
|
||||
* @param string $model
|
||||
* @param RepositoryInterface $repository
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function apply($model, RepositoryInterface $repository)
|
||||
{
|
||||
return $model;
|
||||
}
|
||||
}
|
||||
34
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Stubs/migration/change.stub
vendored
Normal file
34
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Stubs/migration/change.stub
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
/**
|
||||
* Class $CLASS$.
|
||||
*/
|
||||
class $CLASS$ extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('$TABLE$', function(Blueprint $table) {
|
||||
$FIELDS_UP$
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('$TABLE$', function(Blueprint $table) {
|
||||
$FIELDS_DOWN$
|
||||
});
|
||||
}
|
||||
}
|
||||
34
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Stubs/migration/create.stub
vendored
Normal file
34
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Stubs/migration/create.stub
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
/**
|
||||
* Class $CLASS$.
|
||||
*/
|
||||
class $CLASS$ extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('$TABLE$', function(Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$FIELDS$
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('$TABLE$');
|
||||
}
|
||||
}
|
||||
25
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Stubs/model.stub
vendored
Normal file
25
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Stubs/model.stub
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
$NAMESPACE$
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Prettus\Repository\Contracts\Transformable;
|
||||
use Prettus\Repository\Traits\TransformableTrait;
|
||||
|
||||
/**
|
||||
* Class $CLASS$.
|
||||
*
|
||||
* @package $NAMESPACE$
|
||||
*/
|
||||
class $CLASS$ extends Model implements Transformable
|
||||
{
|
||||
use TransformableTrait;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = $FILLABLE$;
|
||||
|
||||
}
|
||||
24
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Stubs/presenter/presenter.stub
vendored
Normal file
24
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Stubs/presenter/presenter.stub
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
$NAMESPACE$
|
||||
|
||||
use $TRANSFORMER$;
|
||||
use Prettus\Repository\Presenter\FractalPresenter;
|
||||
|
||||
/**
|
||||
* Class $CLASS$Presenter.
|
||||
*
|
||||
* @package $NAMESPACE$
|
||||
*/
|
||||
class $CLASS$Presenter extends FractalPresenter
|
||||
{
|
||||
/**
|
||||
* Transformer
|
||||
*
|
||||
* @return \League\Fractal\TransformerAbstract
|
||||
*/
|
||||
public function getTransformer()
|
||||
{
|
||||
return new $CLASS$Transformer();
|
||||
}
|
||||
}
|
||||
38
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Stubs/repository/eloquent.stub
vendored
Normal file
38
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Stubs/repository/eloquent.stub
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
$NAMESPACE$
|
||||
|
||||
use Prettus\Repository\Eloquent\BaseRepository;
|
||||
use Prettus\Repository\Criteria\RequestCriteria;
|
||||
use $REPOSITORY$
|
||||
use $MODEL$;
|
||||
$USE_VALIDATOR$
|
||||
|
||||
/**
|
||||
* Class $CLASS$RepositoryEloquent.
|
||||
*
|
||||
* @package $NAMESPACE$
|
||||
*/
|
||||
class $CLASS$RepositoryEloquent extends BaseRepository implements $CLASS$Repository
|
||||
{
|
||||
/**
|
||||
* Specify Model class name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function model()
|
||||
{
|
||||
return $CLASS$::class;
|
||||
}
|
||||
|
||||
$VALIDATOR$
|
||||
|
||||
/**
|
||||
* Boot up the repository, pushing criteria
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->pushCriteria(app(RequestCriteria::class));
|
||||
}
|
||||
|
||||
}
|
||||
15
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Stubs/repository/interface.stub
vendored
Normal file
15
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Stubs/repository/interface.stub
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
$NAMESPACE$
|
||||
|
||||
use Prettus\Repository\Contracts\RepositoryInterface;
|
||||
|
||||
/**
|
||||
* Interface $CLASS$Repository.
|
||||
*
|
||||
* @package $NAMESPACE$
|
||||
*/
|
||||
interface $CLASS$Repository extends RepositoryInterface
|
||||
{
|
||||
//
|
||||
}
|
||||
25
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Stubs/seed.stub
vendored
Normal file
25
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Stubs/seed.stub
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
$NAMESPACE$
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class $CLASS$.
|
||||
*/
|
||||
class $CLASS$ extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
Model::unguard();
|
||||
|
||||
// $this->call("OthersTableSeeder");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
$NAMESPACE$
|
||||
|
||||
use League\Fractal\TransformerAbstract;
|
||||
use $MODEL$;
|
||||
|
||||
/**
|
||||
* Class $CLASS$Transformer.
|
||||
*
|
||||
* @package $NAMESPACE$
|
||||
*/
|
||||
class $CLASS$Transformer extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* Transform the $CLASS$ entity.
|
||||
*
|
||||
* @param \$MODEL$ $model
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function transform($CLASS$ $model)
|
||||
{
|
||||
return [
|
||||
'id' => (int) $model->id,
|
||||
|
||||
/* place your other model properties here */
|
||||
|
||||
'created_at' => $model->created_at,
|
||||
'updated_at' => $model->updated_at
|
||||
];
|
||||
}
|
||||
}
|
||||
24
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Stubs/validator/validator.stub
vendored
Normal file
24
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/Stubs/validator/validator.stub
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
$NAMESPACE$
|
||||
|
||||
use \Prettus\Validator\Contracts\ValidatorInterface;
|
||||
use \Prettus\Validator\LaravelValidator;
|
||||
|
||||
/**
|
||||
* Class $CLASS$Validator.
|
||||
*
|
||||
* @package $NAMESPACE$
|
||||
*/
|
||||
class $CLASS$Validator extends LaravelValidator
|
||||
{
|
||||
/**
|
||||
* Validation Rules
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $rules = [
|
||||
ValidatorInterface::RULE_CREATE => $RULES$,
|
||||
ValidatorInterface::RULE_UPDATE => $RULES$,
|
||||
];
|
||||
}
|
||||
78
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/TransformerGenerator.php
vendored
Normal file
78
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/TransformerGenerator.php
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
namespace Prettus\Repository\Generators;
|
||||
|
||||
/**
|
||||
* Class TransformerGenerator
|
||||
* @package Prettus\Repository\Generators
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
class TransformerGenerator extends Generator
|
||||
{
|
||||
/**
|
||||
* Get stub name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $stub = 'transformer/transformer';
|
||||
|
||||
/**
|
||||
* Get root namespace.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRootNamespace()
|
||||
{
|
||||
return parent::getRootNamespace() . parent::getConfigGeneratorClassPath($this->getPathConfigNode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get generator path config node.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPathConfigNode()
|
||||
{
|
||||
return 'transformers';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get destination path for generated file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPath()
|
||||
{
|
||||
return $this->getBasePath() . '/' . parent::getConfigGeneratorClassPath($this->getPathConfigNode(), true) . '/' . $this->getName() . 'Transformer.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get base path of destination file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBasePath()
|
||||
{
|
||||
return config('repository.generator.basePath', app()->path());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get array replacements.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getReplacements()
|
||||
{
|
||||
$modelGenerator = new ModelGenerator([
|
||||
'name' => $this->name
|
||||
]);
|
||||
$model = $modelGenerator->getRootNamespace() . '\\' . $modelGenerator->getName();
|
||||
$model = str_replace([
|
||||
"\\",
|
||||
'/'
|
||||
], '\\', $model);
|
||||
|
||||
return array_merge(parent::getReplacements(), [
|
||||
'model' => $model
|
||||
]);
|
||||
}
|
||||
}
|
||||
103
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/ValidatorGenerator.php
vendored
Normal file
103
vendor/prettus/l5-repository/src/Prettus/Repository/Generators/ValidatorGenerator.php
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
namespace Prettus\Repository\Generators;
|
||||
|
||||
use Prettus\Repository\Generators\Migrations\RulesParser;
|
||||
use Prettus\Repository\Generators\Migrations\SchemaParser;
|
||||
|
||||
/**
|
||||
* Class ValidatorGenerator
|
||||
* @package Prettus\Repository\Generators
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
class ValidatorGenerator extends Generator
|
||||
{
|
||||
|
||||
/**
|
||||
* Get stub name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $stub = 'validator/validator';
|
||||
|
||||
/**
|
||||
* Get root namespace.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRootNamespace()
|
||||
{
|
||||
return parent::getRootNamespace() . parent::getConfigGeneratorClassPath($this->getPathConfigNode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get generator path config node.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPathConfigNode()
|
||||
{
|
||||
return 'validators';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get destination path for generated file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPath()
|
||||
{
|
||||
return $this->getBasePath() . '/' . parent::getConfigGeneratorClassPath($this->getPathConfigNode(), true) . '/' . $this->getName() . 'Validator.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get base path of destination file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBasePath()
|
||||
{
|
||||
return config('repository.generator.basePath', app()->path());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get array replacements.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getReplacements()
|
||||
{
|
||||
|
||||
return array_merge(parent::getReplacements(), [
|
||||
'rules' => $this->getRules(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the rules.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRules()
|
||||
{
|
||||
if (!$this->rules) {
|
||||
return '[]';
|
||||
}
|
||||
$results = '[' . PHP_EOL;
|
||||
|
||||
foreach ($this->getSchemaParser()->toArray() as $column => $value) {
|
||||
$results .= "\t\t'{$column}'\t=>'\t{$value}'," . PHP_EOL;
|
||||
}
|
||||
|
||||
return $results . "\t" . ']';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get schema parser.
|
||||
*
|
||||
* @return SchemaParser
|
||||
*/
|
||||
public function getSchemaParser()
|
||||
{
|
||||
return new RulesParser($this->rules);
|
||||
}
|
||||
}
|
||||
129
vendor/prettus/l5-repository/src/Prettus/Repository/Helpers/CacheKeys.php
vendored
Normal file
129
vendor/prettus/l5-repository/src/Prettus/Repository/Helpers/CacheKeys.php
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
namespace Prettus\Repository\Helpers;
|
||||
|
||||
/**
|
||||
* Class CacheKeys
|
||||
* @package Prettus\Repository\Helpers
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
class CacheKeys
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected static $storeFile = "repository-cache-keys.json";
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected static $keys = null;
|
||||
|
||||
/**
|
||||
* @param $group
|
||||
* @param $key
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function putKey($group, $key)
|
||||
{
|
||||
self::loadKeys();
|
||||
|
||||
self::$keys[$group] = self::getKeys($group);
|
||||
|
||||
if (!in_array($key, self::$keys[$group])) {
|
||||
self::$keys[$group][] = $key;
|
||||
}
|
||||
|
||||
self::storeKeys();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|mixed
|
||||
*/
|
||||
public static function loadKeys()
|
||||
{
|
||||
if (!is_null(self::$keys) && is_array(self::$keys)) {
|
||||
return self::$keys;
|
||||
}
|
||||
|
||||
$file = self::getFileKeys();
|
||||
|
||||
if (!file_exists($file)) {
|
||||
self::storeKeys();
|
||||
}
|
||||
|
||||
$content = file_get_contents($file);
|
||||
self::$keys = json_decode($content, true);
|
||||
|
||||
return self::$keys;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getFileKeys()
|
||||
{
|
||||
$file = storage_path("framework/cache/" . self::$storeFile);
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public static function storeKeys()
|
||||
{
|
||||
$file = self::getFileKeys();
|
||||
self::$keys = is_null(self::$keys) ? [] : self::$keys;
|
||||
$content = json_encode(self::$keys);
|
||||
|
||||
return file_put_contents($file, $content);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $group
|
||||
*
|
||||
* @return array|mixed
|
||||
*/
|
||||
public static function getKeys($group)
|
||||
{
|
||||
self::loadKeys();
|
||||
self::$keys[$group] = isset(self::$keys[$group]) ? self::$keys[$group] : [];
|
||||
|
||||
return self::$keys[$group];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $method
|
||||
* @param $parameters
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function __callStatic($method, $parameters)
|
||||
{
|
||||
$instance = new static;
|
||||
|
||||
return call_user_func_array([
|
||||
$instance,
|
||||
$method
|
||||
], $parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $method
|
||||
* @param $parameters
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($method, $parameters)
|
||||
{
|
||||
$instance = new static;
|
||||
|
||||
return call_user_func_array([
|
||||
$instance,
|
||||
$method
|
||||
], $parameters);
|
||||
}
|
||||
}
|
||||
76
vendor/prettus/l5-repository/src/Prettus/Repository/Listeners/CleanCacheRepository.php
vendored
Normal file
76
vendor/prettus/l5-repository/src/Prettus/Repository/Listeners/CleanCacheRepository.php
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace Prettus\Repository\Listeners;
|
||||
|
||||
use Illuminate\Contracts\Cache\Repository as CacheRepository;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Prettus\Repository\Contracts\RepositoryInterface;
|
||||
use Prettus\Repository\Events\RepositoryEventBase;
|
||||
use Prettus\Repository\Helpers\CacheKeys;
|
||||
|
||||
/**
|
||||
* Class CleanCacheRepository
|
||||
* @package Prettus\Repository\Listeners
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
class CleanCacheRepository
|
||||
{
|
||||
|
||||
/**
|
||||
* @var CacheRepository
|
||||
*/
|
||||
protected $cache = null;
|
||||
|
||||
/**
|
||||
* @var RepositoryInterface
|
||||
*/
|
||||
protected $repository = null;
|
||||
|
||||
/**
|
||||
* @var Model
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $action = null;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->cache = app(config('repository.cache.repository', 'cache'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RepositoryEventBase $event
|
||||
*/
|
||||
public function handle(RepositoryEventBase $event)
|
||||
{
|
||||
try {
|
||||
$cleanEnabled = config("repository.cache.clean.enabled", true);
|
||||
|
||||
if ($cleanEnabled) {
|
||||
$this->repository = $event->getRepository();
|
||||
$this->model = $event->getModel();
|
||||
$this->action = $event->getAction();
|
||||
|
||||
if (config("repository.cache.clean.on.{$this->action}", true)) {
|
||||
$cacheKeys = CacheKeys::getKeys(get_class($this->repository));
|
||||
|
||||
if (is_array($cacheKeys)) {
|
||||
foreach ($cacheKeys as $key) {
|
||||
$this->cache->forget($key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
164
vendor/prettus/l5-repository/src/Prettus/Repository/Presenter/FractalPresenter.php
vendored
Normal file
164
vendor/prettus/l5-repository/src/Prettus/Repository/Presenter/FractalPresenter.php
vendored
Normal file
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
namespace Prettus\Repository\Presenter;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
|
||||
use Illuminate\Pagination\AbstractPaginator;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Pagination\Paginator;
|
||||
use League\Fractal\Manager;
|
||||
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
||||
use League\Fractal\Resource\Collection;
|
||||
use League\Fractal\Resource\Item;
|
||||
use League\Fractal\Serializer\SerializerAbstract;
|
||||
use Prettus\Repository\Contracts\PresenterInterface;
|
||||
|
||||
/**
|
||||
* Class FractalPresenter
|
||||
* @package Prettus\Repository\Presenter
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
abstract class FractalPresenter implements PresenterInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $resourceKeyItem = null;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $resourceKeyCollection = null;
|
||||
|
||||
/**
|
||||
* @var \League\Fractal\Manager
|
||||
*/
|
||||
protected $fractal = null;
|
||||
|
||||
/**
|
||||
* @var \League\Fractal\Resource\Collection
|
||||
*/
|
||||
protected $resource = null;
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
if (!class_exists('League\Fractal\Manager')) {
|
||||
throw new Exception(trans('repository::packages.league_fractal_required'));
|
||||
}
|
||||
|
||||
$this->fractal = new Manager();
|
||||
$this->parseIncludes();
|
||||
$this->setupSerializer();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
protected function setupSerializer()
|
||||
{
|
||||
$serializer = $this->serializer();
|
||||
|
||||
if ($serializer instanceof SerializerAbstract) {
|
||||
$this->fractal->setSerializer(new $serializer());
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
protected function parseIncludes()
|
||||
{
|
||||
|
||||
$request = app('Illuminate\Http\Request');
|
||||
$paramIncludes = config('repository.fractal.params.include', 'include');
|
||||
|
||||
if ($request->has($paramIncludes)) {
|
||||
$this->fractal->parseIncludes($request->get($paramIncludes));
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Serializer
|
||||
*
|
||||
* @return SerializerAbstract
|
||||
*/
|
||||
public function serializer()
|
||||
{
|
||||
$serializer = config('repository.fractal.serializer', 'League\\Fractal\\Serializer\\DataArraySerializer');
|
||||
|
||||
return new $serializer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Transformer
|
||||
*
|
||||
* @return \League\Fractal\TransformerAbstract
|
||||
*/
|
||||
abstract public function getTransformer();
|
||||
|
||||
/**
|
||||
* Prepare data to present
|
||||
*
|
||||
* @param $data
|
||||
*
|
||||
* @return mixed
|
||||
* @throws Exception
|
||||
*/
|
||||
public function present($data)
|
||||
{
|
||||
if (!class_exists('League\Fractal\Manager')) {
|
||||
throw new Exception(trans('repository::packages.league_fractal_required'));
|
||||
}
|
||||
|
||||
if ($data instanceof EloquentCollection) {
|
||||
$this->resource = $this->transformCollection($data);
|
||||
} elseif ($data instanceof AbstractPaginator) {
|
||||
$this->resource = $this->transformPaginator($data);
|
||||
} else {
|
||||
$this->resource = $this->transformItem($data);
|
||||
}
|
||||
|
||||
return $this->fractal->createData($this->resource)->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
*
|
||||
* @return Item
|
||||
*/
|
||||
protected function transformItem($data)
|
||||
{
|
||||
return new Item($data, $this->getTransformer(), $this->resourceKeyItem);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
*
|
||||
* @return \League\Fractal\Resource\Collection
|
||||
*/
|
||||
protected function transformCollection($data)
|
||||
{
|
||||
return new Collection($data, $this->getTransformer(), $this->resourceKeyCollection);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AbstractPaginator|LengthAwarePaginator|Paginator $paginator
|
||||
*
|
||||
* @return \League\Fractal\Resource\Collection
|
||||
*/
|
||||
protected function transformPaginator($paginator)
|
||||
{
|
||||
$collection = $paginator->getCollection();
|
||||
$resource = new Collection($collection, $this->getTransformer(), $this->resourceKeyCollection);
|
||||
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
||||
|
||||
return $resource;
|
||||
}
|
||||
}
|
||||
29
vendor/prettus/l5-repository/src/Prettus/Repository/Presenter/ModelFractalPresenter.php
vendored
Normal file
29
vendor/prettus/l5-repository/src/Prettus/Repository/Presenter/ModelFractalPresenter.php
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
namespace Prettus\Repository\Presenter;
|
||||
|
||||
use Exception;
|
||||
use Prettus\Repository\Transformer\ModelTransformer;
|
||||
|
||||
/**
|
||||
* Class ModelFractalPresenter
|
||||
* @package Prettus\Repository\Presenter
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
class ModelFractalPresenter extends FractalPresenter
|
||||
{
|
||||
|
||||
/**
|
||||
* Transformer
|
||||
*
|
||||
* @return ModelTransformer
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getTransformer()
|
||||
{
|
||||
if (!class_exists('League\Fractal\Manager')) {
|
||||
throw new Exception("Package required. Please install: 'composer require league/fractal' (0.12.*)");
|
||||
}
|
||||
|
||||
return new ModelTransformer();
|
||||
}
|
||||
}
|
||||
64
vendor/prettus/l5-repository/src/Prettus/Repository/Providers/EventServiceProvider.php
vendored
Normal file
64
vendor/prettus/l5-repository/src/Prettus/Repository/Providers/EventServiceProvider.php
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
namespace Prettus\Repository\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
/**
|
||||
* Class EventServiceProvider
|
||||
* @package Prettus\Repository\Providers
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* The event handler mappings for the application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $listen = [
|
||||
'Prettus\Repository\Events\RepositoryEntityCreated' => [
|
||||
'Prettus\Repository\Listeners\CleanCacheRepository'
|
||||
],
|
||||
'Prettus\Repository\Events\RepositoryEntityUpdated' => [
|
||||
'Prettus\Repository\Listeners\CleanCacheRepository'
|
||||
],
|
||||
'Prettus\Repository\Events\RepositoryEntityDeleted' => [
|
||||
'Prettus\Repository\Listeners\CleanCacheRepository'
|
||||
]
|
||||
];
|
||||
|
||||
/**
|
||||
* Register the application's event listeners.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$events = app('events');
|
||||
|
||||
foreach ($this->listen as $event => $listeners) {
|
||||
foreach ($listeners as $listener) {
|
||||
$events->listen($event, $listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the events and handlers.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function listens()
|
||||
{
|
||||
return $this->listen;
|
||||
}
|
||||
}
|
||||
40
vendor/prettus/l5-repository/src/Prettus/Repository/Providers/LumenRepositoryServiceProvider.php
vendored
Normal file
40
vendor/prettus/l5-repository/src/Prettus/Repository/Providers/LumenRepositoryServiceProvider.php
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
namespace Prettus\Repository\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
/**
|
||||
* Class LumenRepositoryServiceProvider
|
||||
* @package Prettus\Repository\Providers
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
class LumenRepositoryServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Indicates if loading of the provider is deferred.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $defer = false;
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->commands('Prettus\Repository\Generators\Commands\RepositoryCommand');
|
||||
$this->app->register('Prettus\Repository\Providers\EventServiceProvider');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provides()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
68
vendor/prettus/l5-repository/src/Prettus/Repository/Providers/RepositoryServiceProvider.php
vendored
Normal file
68
vendor/prettus/l5-repository/src/Prettus/Repository/Providers/RepositoryServiceProvider.php
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
namespace Prettus\Repository\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
/**
|
||||
* Class RepositoryServiceProvider
|
||||
* @package Prettus\Repository\Providers
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
class RepositoryServiceProvider extends ServiceProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* Indicates if loading of the provider is deferred.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $defer = false;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->publishes([
|
||||
__DIR__ . '/../../../resources/config/repository.php' => config_path('repository.php')
|
||||
]);
|
||||
|
||||
$this->mergeConfigFrom(__DIR__ . '/../../../resources/config/repository.php', 'repository');
|
||||
|
||||
$this->loadTranslationsFrom(__DIR__ . '/../../../resources/lang', 'repository');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->commands('Prettus\Repository\Generators\Commands\RepositoryCommand');
|
||||
$this->commands('Prettus\Repository\Generators\Commands\ApiRepositoryCommand');
|
||||
$this->commands('Prettus\Repository\Generators\Commands\TransformerCommand');
|
||||
$this->commands('Prettus\Repository\Generators\Commands\PresenterCommand');
|
||||
$this->commands('Prettus\Repository\Generators\Commands\EntityCommand');
|
||||
$this->commands('Prettus\Repository\Generators\Commands\ValidatorCommand');
|
||||
$this->commands('Prettus\Repository\Generators\Commands\ControllerCommand');
|
||||
$this->commands('Prettus\Repository\Generators\Commands\ApiControllerCommand');
|
||||
$this->commands('Prettus\Repository\Generators\Commands\BindingsCommand');
|
||||
$this->commands('Prettus\Repository\Generators\Commands\CriteriaCommand');
|
||||
$this->app->register('Prettus\Repository\Providers\EventServiceProvider');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provides()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
343
vendor/prettus/l5-repository/src/Prettus/Repository/Traits/CacheableRepository.php
vendored
Normal file
343
vendor/prettus/l5-repository/src/Prettus/Repository/Traits/CacheableRepository.php
vendored
Normal file
@@ -0,0 +1,343 @@
|
||||
<?php
|
||||
|
||||
namespace Prettus\Repository\Traits;
|
||||
|
||||
use Illuminate\Contracts\Cache\Repository as CacheRepository;
|
||||
use Prettus\Repository\Contracts\CriteriaInterface;
|
||||
use Prettus\Repository\Helpers\CacheKeys;
|
||||
use ReflectionObject;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Class CacheableRepository
|
||||
* @package Prettus\Repository\Traits
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
trait CacheableRepository
|
||||
{
|
||||
|
||||
/**
|
||||
* @var CacheRepository
|
||||
*/
|
||||
protected $cacheRepository = null;
|
||||
|
||||
/**
|
||||
* Set Cache Repository
|
||||
*
|
||||
* @param CacheRepository $repository
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCacheRepository(CacheRepository $repository)
|
||||
{
|
||||
$this->cacheRepository = $repository;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return instance of Cache Repository
|
||||
*
|
||||
* @return CacheRepository
|
||||
*/
|
||||
public function getCacheRepository()
|
||||
{
|
||||
if (is_null($this->cacheRepository)) {
|
||||
$this->cacheRepository = app(config('repository.cache.repository', 'cache'));
|
||||
}
|
||||
|
||||
return $this->cacheRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Skip Cache
|
||||
*
|
||||
* @param bool $status
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function skipCache($status = true)
|
||||
{
|
||||
$this->cacheSkip = $status;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isSkippedCache()
|
||||
{
|
||||
$skipped = isset($this->cacheSkip) ? $this->cacheSkip : false;
|
||||
$request = app('Illuminate\Http\Request');
|
||||
$skipCacheParam = config('repository.cache.params.skipCache', 'skipCache');
|
||||
|
||||
if ($request->has($skipCacheParam) && $request->get($skipCacheParam)) {
|
||||
$skipped = true;
|
||||
}
|
||||
|
||||
return $skipped;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $method
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function allowedCache($method)
|
||||
{
|
||||
$cacheEnabled = config('repository.cache.enabled', true);
|
||||
|
||||
if (!$cacheEnabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$cacheOnly = isset($this->cacheOnly) ? $this->cacheOnly : config('repository.cache.allowed.only', null);
|
||||
$cacheExcept = isset($this->cacheExcept) ? $this->cacheExcept : config('repository.cache.allowed.except', null);
|
||||
|
||||
if (is_array($cacheOnly)) {
|
||||
return in_array($method, $cacheOnly);
|
||||
}
|
||||
|
||||
if (is_array($cacheExcept)) {
|
||||
return !in_array($method, $cacheExcept);
|
||||
}
|
||||
|
||||
if (is_null($cacheOnly) && is_null($cacheExcept)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Cache key for the method
|
||||
*
|
||||
* @param $method
|
||||
* @param $args
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCacheKey($method, $args = null)
|
||||
{
|
||||
|
||||
$request = app('Illuminate\Http\Request');
|
||||
$args = serialize($args);
|
||||
$criteria = $this->serializeCriteria();
|
||||
$key = sprintf('%s@%s-%s', get_called_class(), $method, md5($args . $criteria . $request->fullUrl()));
|
||||
|
||||
CacheKeys::putKey(get_called_class(), $key);
|
||||
|
||||
return $key;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize the criteria making sure the Closures are taken care of.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function serializeCriteria()
|
||||
{
|
||||
try {
|
||||
return serialize($this->getCriteria());
|
||||
} catch (Exception $e) {
|
||||
return serialize($this->getCriteria()->map(function ($criterion) {
|
||||
return $this->serializeCriterion($criterion);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize single criterion with customized serialization of Closures.
|
||||
*
|
||||
* @param \Prettus\Repository\Contracts\CriteriaInterface $criterion
|
||||
* @return \Prettus\Repository\Contracts\CriteriaInterface|array
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function serializeCriterion($criterion)
|
||||
{
|
||||
try {
|
||||
serialize($criterion);
|
||||
|
||||
return $criterion;
|
||||
} catch (Exception $e) {
|
||||
// We want to take care of the closure serialization errors,
|
||||
// other than that we will simply re-throw the exception.
|
||||
if ($e->getMessage() !== "Serialization of 'Closure' is not allowed") {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
$r = new ReflectionObject($criterion);
|
||||
|
||||
return [
|
||||
'hash' => md5((string) $r),
|
||||
'properties' => $r->getProperties(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cache minutes
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCacheMinutes()
|
||||
{
|
||||
$cacheMinutes = isset($this->cacheMinutes) ? $this->cacheMinutes : config('repository.cache.minutes', 30);
|
||||
|
||||
return $cacheMinutes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve all data of repository
|
||||
*
|
||||
* @param array $columns
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function all($columns = ['*'])
|
||||
{
|
||||
if (!$this->allowedCache('all') || $this->isSkippedCache()) {
|
||||
return parent::all($columns);
|
||||
}
|
||||
|
||||
$key = $this->getCacheKey('all', func_get_args());
|
||||
$minutes = $this->getCacheMinutes();
|
||||
$value = $this->getCacheRepository()->remember($key, $minutes, function () use ($columns) {
|
||||
return parent::all($columns);
|
||||
});
|
||||
|
||||
$this->resetModel();
|
||||
$this->resetScope();
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve all data of repository, paginated
|
||||
*
|
||||
* @param null $limit
|
||||
* @param array $columns
|
||||
* @param string $method
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function paginate($limit = null, $columns = ['*'], $method = 'paginate')
|
||||
{
|
||||
if (!$this->allowedCache('paginate') || $this->isSkippedCache()) {
|
||||
return parent::paginate($limit, $columns, $method);
|
||||
}
|
||||
|
||||
$key = $this->getCacheKey('paginate', func_get_args());
|
||||
|
||||
$minutes = $this->getCacheMinutes();
|
||||
$value = $this->getCacheRepository()->remember($key, $minutes, function () use ($limit, $columns, $method) {
|
||||
return parent::paginate($limit, $columns, $method);
|
||||
});
|
||||
|
||||
$this->resetModel();
|
||||
$this->resetScope();
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find data by id
|
||||
*
|
||||
* @param $id
|
||||
* @param array $columns
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function find($id, $columns = ['*'])
|
||||
{
|
||||
if (!$this->allowedCache('find') || $this->isSkippedCache()) {
|
||||
return parent::find($id, $columns);
|
||||
}
|
||||
|
||||
$key = $this->getCacheKey('find', func_get_args());
|
||||
$minutes = $this->getCacheMinutes();
|
||||
$value = $this->getCacheRepository()->remember($key, $minutes, function () use ($id, $columns) {
|
||||
return parent::find($id, $columns);
|
||||
});
|
||||
|
||||
$this->resetModel();
|
||||
$this->resetScope();
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find data by field and value
|
||||
*
|
||||
* @param $field
|
||||
* @param $value
|
||||
* @param array $columns
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function findByField($field, $value = null, $columns = ['*'])
|
||||
{
|
||||
if (!$this->allowedCache('findByField') || $this->isSkippedCache()) {
|
||||
return parent::findByField($field, $value, $columns);
|
||||
}
|
||||
|
||||
$key = $this->getCacheKey('findByField', func_get_args());
|
||||
$minutes = $this->getCacheMinutes();
|
||||
$value = $this->getCacheRepository()->remember($key, $minutes, function () use ($field, $value, $columns) {
|
||||
return parent::findByField($field, $value, $columns);
|
||||
});
|
||||
|
||||
$this->resetModel();
|
||||
$this->resetScope();
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find data by multiple fields
|
||||
*
|
||||
* @param array $where
|
||||
* @param array $columns
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function findWhere(array $where, $columns = ['*'])
|
||||
{
|
||||
if (!$this->allowedCache('findWhere') || $this->isSkippedCache()) {
|
||||
return parent::findWhere($where, $columns);
|
||||
}
|
||||
|
||||
$key = $this->getCacheKey('findWhere', func_get_args());
|
||||
$minutes = $this->getCacheMinutes();
|
||||
$value = $this->getCacheRepository()->remember($key, $minutes, function () use ($where, $columns) {
|
||||
return parent::findWhere($where, $columns);
|
||||
});
|
||||
|
||||
$this->resetModel();
|
||||
$this->resetScope();
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find data by Criteria
|
||||
*
|
||||
* @param CriteriaInterface $criteria
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getByCriteria(CriteriaInterface $criteria)
|
||||
{
|
||||
if (!$this->allowedCache('getByCriteria') || $this->isSkippedCache()) {
|
||||
return parent::getByCriteria($criteria);
|
||||
}
|
||||
|
||||
$key = $this->getCacheKey('getByCriteria', func_get_args());
|
||||
$minutes = $this->getCacheMinutes();
|
||||
$value = $this->getCacheRepository()->remember($key, $minutes, function () use ($criteria) {
|
||||
return parent::getByCriteria($criteria);
|
||||
});
|
||||
|
||||
$this->resetModel();
|
||||
$this->resetScope();
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
30
vendor/prettus/l5-repository/src/Prettus/Repository/Traits/ComparesVersionsTrait.php
vendored
Normal file
30
vendor/prettus/l5-repository/src/Prettus/Repository/Traits/ComparesVersionsTrait.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
namespace Prettus\Repository\Traits;
|
||||
|
||||
/**
|
||||
* Trait ComparesVersionsTrait
|
||||
* @package Prettus\Repository\Traits
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
trait ComparesVersionsTrait
|
||||
{
|
||||
/**
|
||||
* Version compare function that can compare both Laravel and Lumen versions.
|
||||
*
|
||||
* @param string $frameworkVersion
|
||||
* @param string $compareVersion
|
||||
* @param string|null $operator
|
||||
* @return mixed
|
||||
*/
|
||||
public function versionCompare($frameworkVersion, $compareVersion, $operator = null)
|
||||
{
|
||||
// Lumen (5.5.2) (Laravel Components 5.5.*)
|
||||
$lumenPattern = '/Lumen \((\d\.\d\.[\d|\*])\)( \(Laravel Components (\d\.\d\.[\d|\*])\))?/';
|
||||
|
||||
if (preg_match($lumenPattern, $frameworkVersion, $matches)) {
|
||||
$frameworkVersion = isset($matches[3]) ? $matches[3] : $matches[1]; // Prefer Laravel Components version.
|
||||
}
|
||||
|
||||
return version_compare($frameworkVersion, $compareVersion, $operator);
|
||||
}
|
||||
}
|
||||
69
vendor/prettus/l5-repository/src/Prettus/Repository/Traits/PresentableTrait.php
vendored
Normal file
69
vendor/prettus/l5-repository/src/Prettus/Repository/Traits/PresentableTrait.php
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace Prettus\Repository\Traits;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Prettus\Repository\Contracts\PresenterInterface;
|
||||
|
||||
/**
|
||||
* Class PresentableTrait
|
||||
* @package Prettus\Repository\Traits
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
trait PresentableTrait
|
||||
{
|
||||
|
||||
/**
|
||||
* @var PresenterInterface
|
||||
*/
|
||||
protected $presenter = null;
|
||||
|
||||
/**
|
||||
* @param \Prettus\Repository\Contracts\PresenterInterface $presenter
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPresenter(PresenterInterface $presenter)
|
||||
{
|
||||
$this->presenter = $presenter;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $key
|
||||
* @param null $default
|
||||
*
|
||||
* @return mixed|null
|
||||
*/
|
||||
public function present($key, $default = null)
|
||||
{
|
||||
if ($this->hasPresenter()) {
|
||||
$data = $this->presenter()['data'];
|
||||
|
||||
return Arr::get($data, $key, $default);
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function hasPresenter()
|
||||
{
|
||||
return isset($this->presenter) && $this->presenter instanceof PresenterInterface;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this|mixed
|
||||
*/
|
||||
public function presenter()
|
||||
{
|
||||
if ($this->hasPresenter()) {
|
||||
return $this->presenter->present($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
121
vendor/prettus/l5-repository/src/Prettus/Repository/Traits/Respondable.php
vendored
Normal file
121
vendor/prettus/l5-repository/src/Prettus/Repository/Traits/Respondable.php
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
namespace Prettus\Repository\Traits;
|
||||
|
||||
trait Respondable {
|
||||
/**
|
||||
* Return generic json response with the given data.
|
||||
*
|
||||
* @param $data
|
||||
* @param int $statusCode
|
||||
* @param array $headers
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
protected function respond($data, $statusCode = 200, $headers = [])
|
||||
{
|
||||
return response()->json($data, $statusCode, $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Respond with success.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
protected function respondSuccess()
|
||||
{
|
||||
return $this->respond(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Respond with created.
|
||||
*
|
||||
* @param $data
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
protected function respondCreated($data)
|
||||
{
|
||||
return $this->respond($data, 201);
|
||||
}
|
||||
|
||||
/**
|
||||
* Respond with no content.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
protected function respondNoContent()
|
||||
{
|
||||
return $this->respond(null, 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Respond with error.
|
||||
*
|
||||
* @param $message
|
||||
* @param $statusCode
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
protected function respondError($message, $statusCode)
|
||||
{
|
||||
return $this->respond([
|
||||
'errors' => [
|
||||
'message' => $message,
|
||||
'status_code' => $statusCode
|
||||
]
|
||||
], $statusCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Respond with unauthorized.
|
||||
*
|
||||
* @param string $message
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
protected function respondUnauthorized($message = 'Unauthorized')
|
||||
{
|
||||
return $this->respondError($message, 401);
|
||||
}
|
||||
|
||||
/**
|
||||
* Respond with forbidden.
|
||||
*
|
||||
* @param string $message
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
protected function respondForbidden($message = 'Forbidden')
|
||||
{
|
||||
return $this->respondError($message, 403);
|
||||
}
|
||||
|
||||
/**
|
||||
* Respond with not found.
|
||||
*
|
||||
* @param string $message
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
protected function respondNotFound($message = 'Not Found')
|
||||
{
|
||||
return $this->respondError($message, 404);
|
||||
}
|
||||
|
||||
/**
|
||||
* Respond with internal error.
|
||||
*
|
||||
* @param string $message
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
protected function respondInternalError($message = 'Internal Error')
|
||||
{
|
||||
return $this->respondError($message, 500);
|
||||
}
|
||||
|
||||
/**
|
||||
* Respond with allow permissions.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
protected function respondCheckPermissions($isAllow)
|
||||
{
|
||||
return $this->respond(['allowed' => $isAllow]);
|
||||
}
|
||||
|
||||
}
|
||||
19
vendor/prettus/l5-repository/src/Prettus/Repository/Traits/TransformableTrait.php
vendored
Normal file
19
vendor/prettus/l5-repository/src/Prettus/Repository/Traits/TransformableTrait.php
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace Prettus\Repository\Traits;
|
||||
|
||||
/**
|
||||
* Class TransformableTrait
|
||||
* @package Prettus\Repository\Traits
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
trait TransformableTrait
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function transform()
|
||||
{
|
||||
return $this->toArray();
|
||||
}
|
||||
}
|
||||
17
vendor/prettus/l5-repository/src/Prettus/Repository/Transformer/ModelTransformer.php
vendored
Normal file
17
vendor/prettus/l5-repository/src/Prettus/Repository/Transformer/ModelTransformer.php
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php namespace Prettus\Repository\Transformer;
|
||||
|
||||
use League\Fractal\TransformerAbstract;
|
||||
use Prettus\Repository\Contracts\Transformable;
|
||||
|
||||
/**
|
||||
* Class ModelTransformer
|
||||
* @package Prettus\Repository\Transformer
|
||||
* @author Anderson Andrade <contato@andersonandra.de>
|
||||
*/
|
||||
class ModelTransformer extends TransformerAbstract
|
||||
{
|
||||
public function transform(Transformable $model)
|
||||
{
|
||||
return $model->transform();
|
||||
}
|
||||
}
|
||||
246
vendor/prettus/l5-repository/src/resources/config/repository.php
vendored
Normal file
246
vendor/prettus/l5-repository/src/resources/config/repository.php
vendored
Normal file
@@ -0,0 +1,246 @@
|
||||
<?php
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Prettus Repository Config
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
|
|
||||
*/
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Repository Pagination Limit Default
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
*/
|
||||
'pagination' => [
|
||||
'limit' => 15
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Fractal Presenter Config
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
|
||||
Available serializers:
|
||||
ArraySerializer
|
||||
DataArraySerializer
|
||||
JsonApiSerializer
|
||||
|
||||
*/
|
||||
'fractal' => [
|
||||
'params' => [
|
||||
'include' => 'include'
|
||||
],
|
||||
'serializer' => League\Fractal\Serializer\DataArraySerializer::class
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache Config
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
*/
|
||||
'cache' => [
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache Status
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Enable or disable cache
|
||||
|
|
||||
*/
|
||||
'enabled' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache Minutes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Time of expiration cache
|
||||
|
|
||||
*/
|
||||
'minutes' => 30,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache Repository
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Instance of Illuminate\Contracts\Cache\Repository
|
||||
|
|
||||
*/
|
||||
'repository' => 'cache',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache Clean Listener
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
|
|
||||
|
|
||||
*/
|
||||
'clean' => [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Enable clear cache on repository changes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
*/
|
||||
'enabled' => true,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Actions in Repository
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| create : Clear Cache on create Entry in repository
|
||||
| update : Clear Cache on update Entry in repository
|
||||
| delete : Clear Cache on delete Entry in repository
|
||||
|
|
||||
*/
|
||||
'on' => [
|
||||
'create' => true,
|
||||
'update' => true,
|
||||
'delete' => true,
|
||||
]
|
||||
],
|
||||
|
||||
'params' => [
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Skip Cache Params
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
|
|
||||
| Ex: http://prettus.local/?search=lorem&skipCache=true
|
||||
|
|
||||
*/
|
||||
'skipCache' => 'skipCache'
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Methods Allowed
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| methods cacheable : all, paginate, find, findByField, findWhere, getByCriteria
|
||||
|
|
||||
| Ex:
|
||||
|
|
||||
| 'only' =>['all','paginate'],
|
||||
|
|
||||
| or
|
||||
|
|
||||
| 'except' =>['find'],
|
||||
*/
|
||||
'allowed' => [
|
||||
'only' => null,
|
||||
'except' => null
|
||||
]
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Criteria Config
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Settings of request parameters names that will be used by Criteria
|
||||
|
|
||||
*/
|
||||
'criteria' => [
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Accepted Conditions
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Conditions accepted in consultations where the Criteria
|
||||
|
|
||||
| Ex:
|
||||
|
|
||||
| 'acceptedConditions'=>['=','like']
|
||||
|
|
||||
| $query->where('foo','=','bar')
|
||||
| $query->where('foo','like','bar')
|
||||
|
|
||||
*/
|
||||
'acceptedConditions' => [
|
||||
'=',
|
||||
'like'
|
||||
],
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Request Params
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Request parameters that will be used to filter the query in the repository
|
||||
|
|
||||
| Params :
|
||||
|
|
||||
| - search : Searched value
|
||||
| Ex: http://prettus.local/?search=lorem
|
||||
|
|
||||
| - searchFields : Fields in which research should be carried out
|
||||
| Ex:
|
||||
| http://prettus.local/?search=lorem&searchFields=name;email
|
||||
| http://prettus.local/?search=lorem&searchFields=name:like;email
|
||||
| http://prettus.local/?search=lorem&searchFields=name:like
|
||||
|
|
||||
| - filter : Fields that must be returned to the response object
|
||||
| Ex:
|
||||
| http://prettus.local/?search=lorem&filter=id,name
|
||||
|
|
||||
| - orderBy : Order By
|
||||
| Ex:
|
||||
| http://prettus.local/?search=lorem&orderBy=id
|
||||
|
|
||||
| - sortedBy : Sort
|
||||
| Ex:
|
||||
| http://prettus.local/?search=lorem&orderBy=id&sortedBy=asc
|
||||
| http://prettus.local/?search=lorem&orderBy=id&sortedBy=desc
|
||||
|
|
||||
| - searchJoin: Specifies the search method (AND / OR), by default the
|
||||
| application searches each parameter with OR
|
||||
| EX:
|
||||
| http://prettus.local/?search=lorem&searchJoin=and
|
||||
| http://prettus.local/?search=lorem&searchJoin=or
|
||||
|
|
||||
*/
|
||||
'params' => [
|
||||
'search' => 'search',
|
||||
'searchFields' => 'searchFields',
|
||||
'filter' => 'filter',
|
||||
'orderBy' => 'orderBy',
|
||||
'sortedBy' => 'sortedBy',
|
||||
'with' => 'with',
|
||||
'searchJoin' => 'searchJoin',
|
||||
'withCount' => 'withCount'
|
||||
]
|
||||
],
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Generator Config
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
*/
|
||||
'generator' => [
|
||||
'api' => false,
|
||||
'basePath' => app()->path(),
|
||||
'rootNamespace' => 'App\\',
|
||||
'stubsOverridePath' => app()->path(),
|
||||
'paths' => [
|
||||
'models' => 'Entities',
|
||||
'repositories' => 'Repositories',
|
||||
'interfaces' => 'Repositories',
|
||||
'transformers' => 'Transformers',
|
||||
'presenters' => 'Presenters',
|
||||
'validators' => 'Validators',
|
||||
'controllers' => 'Http/Controllers',
|
||||
'provider' => 'RepositoryServiceProvider',
|
||||
'criteria' => 'Criteria'
|
||||
]
|
||||
]
|
||||
];
|
||||
4
vendor/prettus/l5-repository/src/resources/lang/cn/criteria.php
vendored
Normal file
4
vendor/prettus/l5-repository/src/resources/lang/cn/criteria.php
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
return [
|
||||
'fields_not_accepted' => '不接受的筛选字段 :field'
|
||||
];
|
||||
5
vendor/prettus/l5-repository/src/resources/lang/cn/packages.php
vendored
Normal file
5
vendor/prettus/l5-repository/src/resources/lang/cn/packages.php
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
return [
|
||||
'prettus_laravel_validation_required' => "缺失相关依赖,请通过以下命令进行安装: 'composer require prettus/laravel-validation'",
|
||||
'league_fractal_required' => "缺失相关依赖,请通过以下命令进行安装: 'composer require league/fractal' (0.12.*)"
|
||||
];
|
||||
4
vendor/prettus/l5-repository/src/resources/lang/en/criteria.php
vendored
Normal file
4
vendor/prettus/l5-repository/src/resources/lang/en/criteria.php
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
return [
|
||||
'fields_not_accepted' => 'Columns :field are not accepted in the research'
|
||||
];
|
||||
5
vendor/prettus/l5-repository/src/resources/lang/en/packages.php
vendored
Normal file
5
vendor/prettus/l5-repository/src/resources/lang/en/packages.php
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
return [
|
||||
'prettus_laravel_validation_required' => "Package required. Please install: 'composer require prettus/laravel-validation'",
|
||||
'league_fractal_required' => "Package required. Please install: 'composer require league/fractal' (0.12.*)"
|
||||
];
|
||||
4
vendor/prettus/l5-repository/src/resources/lang/it/criteria.php
vendored
Normal file
4
vendor/prettus/l5-repository/src/resources/lang/it/criteria.php
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
return [
|
||||
'fields_not_accepted' => 'I campi :field non sono accettati nella ricerca'
|
||||
];
|
||||
5
vendor/prettus/l5-repository/src/resources/lang/it/packages.php
vendored
Normal file
5
vendor/prettus/l5-repository/src/resources/lang/it/packages.php
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
return [
|
||||
'prettus_laravel_validation_required' => "Pacchetto richiesto. Installa prettus/laravel-validation ('composer require prettus/laravel-validation'), per favore.",
|
||||
'league_fractal_required' => "Pacchetto richiesto. Installa league/fractal ('composer require league/fractal') (0.12.*), per favore."
|
||||
];
|
||||
4
vendor/prettus/l5-repository/src/resources/lang/nl/criteria.php
vendored
Normal file
4
vendor/prettus/l5-repository/src/resources/lang/nl/criteria.php
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
return [
|
||||
'fields_not_accepted' => 'Kolommen :field worden niet geaccepteerd in de zoekopdracht'
|
||||
];
|
||||
5
vendor/prettus/l5-repository/src/resources/lang/nl/packages.php
vendored
Normal file
5
vendor/prettus/l5-repository/src/resources/lang/nl/packages.php
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
return [
|
||||
'prettus_laravel_validation_required' => "Package vereist. Installeer: 'composer require prettus/laravel-validation'",
|
||||
'league_fractal_required' => "Package vereist. Installeer: 'composer require league/fractal' (0.12.*)"
|
||||
];
|
||||
4
vendor/prettus/l5-repository/src/resources/lang/pt-br/criteria.php
vendored
Normal file
4
vendor/prettus/l5-repository/src/resources/lang/pt-br/criteria.php
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
return [
|
||||
'fields_not_accepted' => 'As colunas :field não são aceitas nessa consulta.'
|
||||
];
|
||||
5
vendor/prettus/l5-repository/src/resources/lang/pt-br/packages.php
vendored
Normal file
5
vendor/prettus/l5-repository/src/resources/lang/pt-br/packages.php
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
return [
|
||||
'prettus_laravel_validation_required' => "Componente requerido. Por favor instale a dependência usando o comando: 'composer require prettus/laravel-validation'",
|
||||
'league_fractal_required' => "Componente requerido. Por favor instale a dependência usando o comando: 'composer require league/fractal' (0.12.*)"
|
||||
];
|
||||
4
vendor/prettus/l5-repository/src/resources/lang/pt/criteria.php
vendored
Normal file
4
vendor/prettus/l5-repository/src/resources/lang/pt/criteria.php
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
return [
|
||||
'fields_not_accepted' => 'As colunas :field não são aceitas nessa consulta.'
|
||||
];
|
||||
5
vendor/prettus/l5-repository/src/resources/lang/pt/packages.php
vendored
Normal file
5
vendor/prettus/l5-repository/src/resources/lang/pt/packages.php
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
return [
|
||||
'prettus_laravel_validation_required' => "Componente requerido. Por favor instale a dependência usando o comando: 'composer require prettus/laravel-validation'",
|
||||
'league_fractal_required' => "Componente requerido. Por favor instale a dependência usando o comando: 'composer require league/fractal' (0.12.*)"
|
||||
];
|
||||
4
vendor/prettus/l5-repository/src/resources/lang/ro/criteria.php
vendored
Normal file
4
vendor/prettus/l5-repository/src/resources/lang/ro/criteria.php
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
return [
|
||||
'fields_not_accepted' => 'Coloanele :field nu sunt acceptate în căutare.'
|
||||
];
|
||||
5
vendor/prettus/l5-repository/src/resources/lang/ro/packages.php
vendored
Normal file
5
vendor/prettus/l5-repository/src/resources/lang/ro/packages.php
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
return [
|
||||
'prettus_laravel_validation_required' => "Pachet obligatoriu. Instalaţi prettus/laravel-validation ('composer require prettus/laravel-validation'), vă rog.",
|
||||
'league_fractal_required' => "Pachet obligatoriu. Instalaţi league/fractal ('composer require league/fractal') (0.12.*), vă rog."
|
||||
];
|
||||
4
vendor/prettus/l5-repository/src/resources/lang/zh_CN/criteria.php
vendored
Normal file
4
vendor/prettus/l5-repository/src/resources/lang/zh_CN/criteria.php
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
return [
|
||||
'fields_not_accepted' => '字段 :field 不支持搜索功能'
|
||||
];
|
||||
5
vendor/prettus/l5-repository/src/resources/lang/zh_CN/packages.php
vendored
Normal file
5
vendor/prettus/l5-repository/src/resources/lang/zh_CN/packages.php
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
return [
|
||||
'prettus_laravel_validation_required' => "需要其它组件。请安装:'composer require prettus/laravel-validation'",
|
||||
'league_fractal_required' => "需要其它组件。请安装:'composer require league/fractal' (0.12.*)"
|
||||
];
|
||||
4
vendor/prettus/l5-repository/src/resources/lang/zh_TW/criteria.php
vendored
Normal file
4
vendor/prettus/l5-repository/src/resources/lang/zh_TW/criteria.php
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
return [
|
||||
'fields_not_accepted' => '欄位 :field 不支援搜尋功能'
|
||||
];
|
||||
5
vendor/prettus/l5-repository/src/resources/lang/zh_TW/packages.php
vendored
Normal file
5
vendor/prettus/l5-repository/src/resources/lang/zh_TW/packages.php
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
return [
|
||||
'prettus_laravel_validation_required' => "需要其它套件。請安裝:'composer require prettus/laravel-validation'",
|
||||
'league_fractal_required' => "需要其它套件。請安裝:'composer require league/fractal' (0.12.*)"
|
||||
];
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user