mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 18:13:11 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0373861536 | ||
|
|
3a4671f3ea | ||
|
|
8515b7ac0b | ||
|
|
541b9508e2 | ||
|
|
afe1fe88ba | ||
|
|
a59a5e1ae1 | ||
|
|
bb3bba2c5b | ||
|
|
5aa0f55d2f | ||
|
|
89b585b242 | ||
|
|
f5b1248a37 | ||
|
|
8b190ac295 | ||
|
|
a861bcaf1b | ||
|
|
bb3bd2645d | ||
|
|
687a8c9b47 | ||
|
|
b1dedc3ee6 | ||
|
|
dac46a081d | ||
|
|
0c38360317 | ||
|
|
1d3a98f0e5 | ||
|
|
d9f79eb128 | ||
|
|
7ef2d2f398 | ||
|
|
5afcbdc7c8 | ||
|
|
8378f1bd67 |
+4
-4
@@ -11,10 +11,10 @@
|
|||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.4.0",
|
"php": ">=5.4.0",
|
||||||
"illuminate/support": "5.0.x",
|
"illuminate/support": "5.0.x|5.1.x",
|
||||||
"illuminate/console": "5.0.x",
|
"illuminate/console": "5.0.x|5.1.x",
|
||||||
"illuminate/filesystem": "5.0.x",
|
"illuminate/filesystem": "5.0.x|5.1.x",
|
||||||
"phpdocumentor/reflection-docblock": "2.0.x",
|
"phpdocumentor/reflection-docblock": "2.0.4",
|
||||||
"symfony/class-loader": "~2.3"
|
"symfony/class-loader": "~2.3"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
|||||||
+31
-1
@@ -84,6 +84,36 @@ return array(
|
|||||||
|
|
||||||
'interfaces' => array(
|
'interfaces' => array(
|
||||||
'\Illuminate\Contracts\Auth\Authenticatable' => config('auth.model', 'App\User'),
|
'\Illuminate\Contracts\Auth\Authenticatable' => config('auth.model', 'App\User'),
|
||||||
)
|
),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Support for custom DB types
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This setting allow you to map any custom database type (that you may have
|
||||||
|
| created using CREATE TYPE statement or imported using database plugin
|
||||||
|
| / extension to a Doctrine type.
|
||||||
|
|
|
||||||
|
| Each key in this array is a name of the Doctrine2 DBAL Platform. Currently valid names are:
|
||||||
|
| 'postgresql', 'db2', 'drizzle', 'mysql', 'oracle', 'sqlanywhere', 'sqlite', 'mssql'
|
||||||
|
|
|
||||||
|
| This name is returned by getName() method of the specific Doctrine/DBAL/Platforms/AbstractPlatform descendant
|
||||||
|
|
|
||||||
|
| The value of the array is an array of type mappings. Key is the name of the custom type,
|
||||||
|
| (for example, "jsonb" from Postgres 9.4) and the value is the name of the corresponding Doctrine2 type (in
|
||||||
|
| our case it is 'json_array'. Doctrine types are listed here:
|
||||||
|
| http://doctrine-dbal.readthedocs.org/en/latest/reference/types.html
|
||||||
|
|
|
||||||
|
| So to support jsonb in your models when working with Postgres, just add the following entry to the array below:
|
||||||
|
|
|
||||||
|
| "postgresql" => array(
|
||||||
|
| "jsonb" => "json_array",
|
||||||
|
| ),
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'custom_db_types' => array(
|
||||||
|
|
||||||
|
),
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -7,8 +7,8 @@
|
|||||||
|
|
||||||
_Checkout [this Laracasts video](https://laracasts.com/series/how-to-be-awesome-in-phpstorm/episodes/15) for a quick introduction/explanation!_
|
_Checkout [this Laracasts video](https://laracasts.com/series/how-to-be-awesome-in-phpstorm/episodes/15) for a quick introduction/explanation!_
|
||||||
|
|
||||||
This packages generates a file that your IDE can understand, so it can provide accurate autocompletion. Generation is done, based on the files in your project, so they are alway up-to-date.
|
This package generates a file that your IDE understands, so it can provide accurate autocompletion. Generation is done based on the files in your project, so they are always up-to-date.
|
||||||
If you don't want to generate it, you can add a pre-generated file to the root folder of your laravel project. (But this isn't as up-to-date as self generated files)
|
If you don't want to generate it, you can add a pre-generated file to the root folder of your Laravel project (but this isn't as up-to-date as self generated files).
|
||||||
|
|
||||||
* Generated version: https://gist.github.com/barryvdh/5227822
|
* Generated version: https://gist.github.com/barryvdh/5227822
|
||||||
|
|
||||||
@@ -16,20 +16,20 @@ Note: You do need CodeIntel for Sublime Text: https://github.com/SublimeCodeInte
|
|||||||
|
|
||||||
### New: PhpStorm Meta for Container instances
|
### New: PhpStorm Meta for Container instances
|
||||||
|
|
||||||
It's possible to generate a PhpStorm meta file, to [add support for factory design pattern](https://confluence.jetbrains.com/display/PhpStorm/PhpStorm+Advanced+Metadata). For Laravel, this means we can make PhpStorm understand what kind of object we are resolving from the IoC Container. For example, `events` will return ann `Illuminate\Events\Dispatcher` object, so with the meta file you can call `app('events')` and it will autocomplete the Dispatcher methods.
|
It's possible to generate a PhpStorm meta file, to [add support for factory design pattern](https://confluence.jetbrains.com/display/PhpStorm/PhpStorm+Advanced+Metadata). For Laravel, this means we can make PhpStorm understand what kind of object we are resolving from the IoC Container. For example, `events` will return an `Illuminate\Events\Dispatcher` object, so with the meta file you can call `app('events')` and it will autocomplete the Dispatcher methods.
|
||||||
|
|
||||||
php artisan ide-helper:meta
|
php artisan ide-helper:meta
|
||||||
|
|
||||||
app('events')->fire();
|
app('events')->fire();
|
||||||
\App::make('events')->fire();
|
\App::make('events')->fire();
|
||||||
|
|
||||||
/** @var \Illuminate\Foundation\Application $app */
|
/** @var \Illuminate\Foundation\Application $app */
|
||||||
$app->make('events')->fire();
|
$app->make('events')->fire();
|
||||||
|
|
||||||
Pre-generated example: https://gist.github.com/barryvdh/bb6ffc5d11e0a75dba67
|
Pre-generated example: https://gist.github.com/barryvdh/bb6ffc5d11e0a75dba67
|
||||||
|
|
||||||
> Note: You might need to restart PhpStorm and make sure `.phpstorm.meta.php` is indexed.
|
> Note: You might need to restart PhpStorm and make sure `.phpstorm.meta.php` is indexed.
|
||||||
> Note: When you receive a FatalException about a class that is not found, check your config (For example, remove S3 as cloud driver when you don't have S3 configured. Remove Redis ServiceProvider when you don't use it.)
|
> Note: When you receive a FatalException about a class that is not found, check your config (for example, remove S3 as cloud driver when you don't have S3 configured. Remove Redis ServiceProvider when you don't use it).
|
||||||
|
|
||||||
### Automatic phpDoc generation for Laravel Facades
|
### Automatic phpDoc generation for Laravel Facades
|
||||||
|
|
||||||
@@ -37,47 +37,47 @@ Require this package with composer using the following command:
|
|||||||
|
|
||||||
composer require barryvdh/laravel-ide-helper
|
composer require barryvdh/laravel-ide-helper
|
||||||
|
|
||||||
After updating composer, add the ServiceProvider to the providers array in config/app.php
|
After updating composer, add the service provider to the `providers` array in `config/app.php`
|
||||||
|
|
||||||
'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider',
|
Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class,
|
||||||
|
|
||||||
You can now re-generate the docs yourself (for future updates) in artisan
|
You can now re-generate the docs yourself (for future updates)
|
||||||
|
|
||||||
php artisan ide-helper:generate
|
php artisan ide-helper:generate
|
||||||
|
|
||||||
Note: bootstrap/compiled.php has to be cleared first, so run `php artisan clear-compiled` before generating (and `php artisan optimize` after..)
|
Note: `bootstrap/compiled.php` has to be cleared first, so run `php artisan clear-compiled` before generating (and `php artisan optimize` after).
|
||||||
|
|
||||||
You can configure your composer.json to do this after each commit:
|
You can configure your composer.json to do this after each commit:
|
||||||
|
|
||||||
"scripts":{
|
"scripts":{
|
||||||
"post-update-cmd":[
|
"post-update-cmd": [
|
||||||
"php artisan clear-compiled",
|
"php artisan clear-compiled",
|
||||||
"php artisan ide-helper:generate",
|
"php artisan ide-helper:generate",
|
||||||
"php artisan optimize"
|
"php artisan optimize"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
You can also publish the config-file to change implementations (ie. interface to specific class) or set defaults for --helpers or --sublime.
|
You can also publish the config file to change implementations (ie. interface to specific class) or set defaults for `--helpers` or `--sublime`.
|
||||||
|
|
||||||
php artisan vendor:publish --provider=barryvdh/laravel-ide-helper --tag=config
|
php artisan vendor:publish --provider=barryvdh/laravel-ide-helper --tag=config
|
||||||
|
|
||||||
The generator tries to identify the real class, but if it cannot be found, you can define it in the config file.
|
The generator tries to identify the real class, but if it cannot be found, you can define it in the config file.
|
||||||
|
|
||||||
Some classes need a working database connection. If you do not have a working default connection, some facades will not be included.
|
Some classes need a working database connection. If you do not have a default working connection, some facades will not be included.
|
||||||
You can use a in-memory sqlite driver, using the -M option.
|
You can use an in-memory SQLite driver, using the -M option.
|
||||||
|
|
||||||
You can choose to include helper files. This is not enabled by default, but you can override this with the --helpers (-H) option.
|
You can choose to include helper files. This is not enabled by default, but you can override it with the `--helpers (-H)` option.
|
||||||
The Illuminate/Support/helpers.php is already set-up, but you can add/remove your own files in the config file.
|
The `Illuminate/Support/helpers.php` is already set-up, but you can add/remove your own files in the config file.
|
||||||
|
|
||||||
### Automatic phpDocs for Models
|
### Automatic phpDocs for models
|
||||||
|
|
||||||
> You need to require `doctrine/dbal: ~2.3` in your own composer.json to get database columns.
|
> You need to require `doctrine/dbal: ~2.3` in your own composer.json to get database columns.
|
||||||
|
|
||||||
If you don't want to write your properties yourself, you can use the command `ide-helper:models` to generate
|
If you don't want to write your properties yourself, you can use the command `php artisan ide-helper:models` to generate
|
||||||
phpDocs, based on table columns, relations and getters/setters. You can write the comments directly to your Model file, using the `--write (-W)` option. By default, you are asked to overwrite or write to a separate file (\_ide\_helper\_models.php) (You can force No with `--nowrite (-N)`).
|
phpDocs, based on table columns, relations and getters/setters. You can write the comments directly to your Model file, using the `--write (-W)` option. By default, you are asked to overwrite or write to a separate file (`_ide_helper_models.php`). You can force No with `--nowrite (-N)`.
|
||||||
Please make sure to backup your models, before writing the info.
|
Please make sure to backup your models, before writing the info.
|
||||||
It should keep the existing comments and only append new properties/methods. The existing phpdoc is replaced, or added if not found.
|
It should keep the existing comments and only append new properties/methods. The existing phpdoc is replaced, or added if not found.
|
||||||
With the `--reset (-R)` option, the existing phpdocs are ignored, only the newly found columns/relations are saved as phpdocs.
|
With the `--reset (-R)` option, the existing phpdocs are ignored, and only the newly found columns/relations are saved as phpdocs.
|
||||||
|
|
||||||
php artisan ide-helper:models Post
|
php artisan ide-helper:models Post
|
||||||
|
|
||||||
@@ -94,17 +94,17 @@ With the `--reset (-R)` option, the existing phpdocs are ignored, only the newly
|
|||||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Comment[] $comments
|
* @property-read \Illuminate\Database\Eloquent\Collection|\Comment[] $comments
|
||||||
*/
|
*/
|
||||||
|
|
||||||
By default, models in app/models are scanned. The optional argument tells what models to use (also outside app/models).
|
By default, models in `app/models` are scanned. The optional argument tells what models to use (also outside app/models).
|
||||||
|
|
||||||
php artisan ide-helper:models Post User
|
php artisan ide-helper:models Post User
|
||||||
|
|
||||||
You can also scan a different directory, using the --dir option (relative from the base path):
|
You can also scan a different directory, using the `--dir` option (relative from the base path):
|
||||||
|
|
||||||
php artisan ide-helper:models --dir="path/to/models" --dir="app/src/Model"
|
php artisan ide-helper:models --dir="path/to/models" --dir="app/src/Model"
|
||||||
|
|
||||||
You can publish the config file (`php artisan vendor:publish`) and set the default directories.
|
You can publish the config file (`php artisan vendor:publish`) and set the default directories.
|
||||||
|
|
||||||
Models can be ignored using the --ignore (-I) option
|
Models can be ignored using the `--ignore (-I)` option
|
||||||
|
|
||||||
php artisan ide-helper:models --ignore="Post,User"
|
php artisan ide-helper:models --ignore="Post,User"
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?= '<?php' ?>
|
<?= '<?php' ?>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An helper file for Laravel 5, to provide autocomplete information to your IDE
|
* A helper file for Laravel 5, to provide autocomplete information to your IDE
|
||||||
* Generated for Laravel <?= $version ?> on <?= date("Y-m-d") ?>.
|
* Generated for Laravel <?= $version ?> on <?= date("Y-m-d") ?>.
|
||||||
*
|
*
|
||||||
* @author Barry vd. Heuvel <[email protected]>
|
* @author Barry vd. Heuvel <[email protected]>
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
<?= '<?php' ?> namespace PHPSTORM_META {
|
<?= '<?php' ?>
|
||||||
|
|
||||||
|
namespace PHPSTORM_META {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PhpStorm Meta file, to provide autocomplete information for PhpStorm
|
* PhpStorm Meta file, to provide autocomplete information for PhpStorm
|
||||||
@@ -7,12 +9,10 @@
|
|||||||
* @author Barry vd. Heuvel <[email protected]>
|
* @author Barry vd. Heuvel <[email protected]>
|
||||||
* @see https://github.com/barryvdh/laravel-ide-helper
|
* @see https://github.com/barryvdh/laravel-ide-helper
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @noinspection PhpIllegalArrayKeyTypeInspection */
|
|
||||||
/** @noinspection PhpUnusedLocalVariableInspection */
|
|
||||||
$STATIC_METHOD_TYPES = [
|
$STATIC_METHOD_TYPES = [
|
||||||
<?php foreach($methods as $method): ?>
|
<?php foreach($methods as $method): ?>
|
||||||
<?= $method ?>('') => [
|
<?= $method ?> => [
|
||||||
|
'' == '@',
|
||||||
<?php foreach($bindings as $abstract => $class): ?>
|
<?php foreach($bindings as $abstract => $class): ?>
|
||||||
'<?= $abstract ?>' instanceof \<?= $class ?>,
|
'<?= $abstract ?>' instanceof \<?= $class ?>,
|
||||||
<?php endforeach ?> ],
|
<?php endforeach ?> ],
|
||||||
|
|||||||
@@ -76,9 +76,11 @@ class GeneratorCommand extends Command
|
|||||||
*/
|
*/
|
||||||
public function fire()
|
public function fire()
|
||||||
{
|
{
|
||||||
if (file_exists($compiled = base_path() . '/bootstrap/compiled.php')) {
|
if (file_exists(base_path() . '/vendor/compiled.php') ||
|
||||||
|
file_exists(base_path() . '/bootstrap/cache/compiled.php') ||
|
||||||
|
file_exists(base_path() . '/storage/framework/compiled.php')) {
|
||||||
$this->error(
|
$this->error(
|
||||||
'Error generating IDE Helper: first delete bootstrap/compiled.php (php artisan clear-compiled)'
|
'Error generating IDE Helper: first delete your compiled file (php artisan clear-compiled)'
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$filename = $this->argument('filename');
|
$filename = $this->argument('filename');
|
||||||
|
|||||||
+21
-18
@@ -12,6 +12,7 @@ namespace Barryvdh\LaravelIdeHelper\Console;
|
|||||||
|
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A command to generate phpstorm meta data
|
* A command to generate phpstorm meta data
|
||||||
@@ -42,12 +43,10 @@ class MetaCommand extends Command {
|
|||||||
protected $view;
|
protected $view;
|
||||||
|
|
||||||
protected $methods = [
|
protected $methods = [
|
||||||
'\Illuminate\Foundation\Application::make',
|
'new \Illuminate\Contracts\Container\Container',
|
||||||
'\Illuminate\Contracts\Foundation\Application::make',
|
'\Illuminate\Contracts\Container\Container::make(\'\')',
|
||||||
'\Illuminate\Contracts\Container\Container::make',
|
'\App::make(\'\')',
|
||||||
'\Illuminate\Container\Container::make',
|
'app(\'\')',
|
||||||
'\App::make',
|
|
||||||
'app',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -68,6 +67,8 @@ class MetaCommand extends Command {
|
|||||||
*/
|
*/
|
||||||
public function fire()
|
public function fire()
|
||||||
{
|
{
|
||||||
|
$this->registerClassAutoloadExceptions();
|
||||||
|
|
||||||
$bindings = array();
|
$bindings = array();
|
||||||
foreach ($this->getAbstracts() as $abstract) {
|
foreach ($this->getAbstracts() as $abstract) {
|
||||||
try {
|
try {
|
||||||
@@ -76,7 +77,9 @@ class MetaCommand extends Command {
|
|||||||
$bindings[$abstract] = get_class($concrete);
|
$bindings[$abstract] = get_class($concrete);
|
||||||
}
|
}
|
||||||
}catch (\Exception $e) {
|
}catch (\Exception $e) {
|
||||||
$this->error("Cannot make $abstract: ".$e->getMessage());
|
if ($this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
|
||||||
|
$this->comment("Cannot make '$abstract': ".$e->getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +99,7 @@ class MetaCommand extends Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a filtered list of abstracts from the Laravel Application.
|
* Get a list of abstracts from the Laravel Application.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
@@ -104,20 +107,20 @@ class MetaCommand extends Command {
|
|||||||
{
|
{
|
||||||
$abstracts = $this->laravel->getBindings();
|
$abstracts = $this->laravel->getBindings();
|
||||||
|
|
||||||
// Remove the S3 cloud driver when not available
|
|
||||||
if (config('filesystems.cloud') === 's3' && !class_exists('League\Flysystem\AwsS3v2\AwsS3Adapter')) {
|
|
||||||
unset($abstracts['filesystem.cloud']);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove Redis when not available
|
|
||||||
if (isset($abstracts['redis']) && !class_exists('Predis\Client')) {
|
|
||||||
unset($abstracts['redis']);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return the abstract names only
|
// Return the abstract names only
|
||||||
return array_keys($abstracts);
|
return array_keys($abstracts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register an autoloader the throws exceptions when a class is not found.
|
||||||
|
*/
|
||||||
|
protected function registerClassAutoloadExceptions()
|
||||||
|
{
|
||||||
|
spl_autoload_register(function ($class) {
|
||||||
|
throw new \Exception("Class '$class' not found.");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the console command options.
|
* Get the console command options.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ use Illuminate\Console\Command;
|
|||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Symfony\Component\ClassLoader\ClassMapGenerator;
|
use Symfony\Component\ClassLoader\ClassMapGenerator;
|
||||||
use phpDocumentor\Reflection\DocBlock;
|
use phpDocumentor\Reflection\DocBlock;
|
||||||
use phpDocumentor\Reflection\DocBlock\Context;
|
use phpDocumentor\Reflection\DocBlock\Context;
|
||||||
@@ -148,7 +149,9 @@ class ModelsCommand extends Command
|
|||||||
|
|
||||||
foreach ($models as $name) {
|
foreach ($models as $name) {
|
||||||
if (in_array($name, $ignore)) {
|
if (in_array($name, $ignore)) {
|
||||||
$this->comment("Ignoring model '$name'");
|
if ($this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
|
||||||
|
$this->comment("Ignoring model '$name'");
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$this->properties = array();
|
$this->properties = array();
|
||||||
@@ -162,7 +165,9 @@ class ModelsCommand extends Command
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->comment("Loading model '$name'");
|
if ($this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
|
||||||
|
$this->comment("Loading model '$name'");
|
||||||
|
}
|
||||||
|
|
||||||
if (!$reflectionClass->IsInstantiable()) {
|
if (!$reflectionClass->IsInstantiable()) {
|
||||||
throw new \Exception($name . ' is not instantiable.');
|
throw new \Exception($name . ' is not instantiable.');
|
||||||
@@ -217,9 +222,21 @@ class ModelsCommand extends Command
|
|||||||
{
|
{
|
||||||
$table = $model->getConnection()->getTablePrefix() . $model->getTable();
|
$table = $model->getConnection()->getTablePrefix() . $model->getTable();
|
||||||
$schema = $model->getConnection()->getDoctrineSchemaManager($table);
|
$schema = $model->getConnection()->getDoctrineSchemaManager($table);
|
||||||
$schema->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
|
$databasePlatform = $schema->getDatabasePlatform();
|
||||||
|
$databasePlatform->registerDoctrineTypeMapping('enum', 'string');
|
||||||
|
|
||||||
$columns = $schema->listTableColumns($table);
|
$platformName = $databasePlatform->getName();
|
||||||
|
$customTypes = $this->laravel['config']->get("ide-helper.custom_db_types.{$platformName}", array());
|
||||||
|
foreach ($customTypes as $yourTypeName => $doctrineTypeName) {
|
||||||
|
$databasePlatform->registerDoctrineTypeMapping($yourTypeName, $doctrineTypeName);
|
||||||
|
}
|
||||||
|
|
||||||
|
$database = null;
|
||||||
|
if (strpos($table, '.')) {
|
||||||
|
list($database, $table) = explode('.', $table);
|
||||||
|
}
|
||||||
|
|
||||||
|
$columns = $schema->listTableColumns($table, $database);
|
||||||
|
|
||||||
if ($columns) {
|
if ($columns) {
|
||||||
foreach ($columns as $column) {
|
foreach ($columns as $column) {
|
||||||
@@ -303,7 +320,7 @@ class ModelsCommand extends Command
|
|||||||
$args = $this->getParameters($reflection);
|
$args = $this->getParameters($reflection);
|
||||||
//Remove the first ($query) argument
|
//Remove the first ($query) argument
|
||||||
array_shift($args);
|
array_shift($args);
|
||||||
$this->setMethod($name, '\\' . $reflection->class, $args);
|
$this->setMethod($name, '\Illuminate\Database\Query\Builder|\\' . $reflection->class, $args);
|
||||||
}
|
}
|
||||||
} elseif (!method_exists('Eloquent', $method) && !Str::startsWith($method, 'get')) {
|
} elseif (!method_exists('Eloquent', $method) && !Str::startsWith($method, 'get')) {
|
||||||
|
|
||||||
@@ -333,7 +350,7 @@ class ModelsCommand extends Command
|
|||||||
$search = '$this->' . $relation . '(';
|
$search = '$this->' . $relation . '(';
|
||||||
if ($pos = stripos($code, $search)) {
|
if ($pos = stripos($code, $search)) {
|
||||||
$code = substr($code, $pos + strlen($search));
|
$code = substr($code, $pos + strlen($search));
|
||||||
$arguments = explode(',', substr($code, 0, strpos($code, ');')));
|
$arguments = explode(',', substr($code, 0, strpos($code, ')')));
|
||||||
//Remove quotes, ensure 1 \ in front of the model
|
//Remove quotes, ensure 1 \ in front of the model
|
||||||
$returnModel = $this->getClassName($arguments[0], $model);
|
$returnModel = $this->getClassName($arguments[0], $model);
|
||||||
if ($relation === "belongsToMany" or $relation === 'hasMany' or $relation === 'morphMany' or $relation === 'morphToMany') {
|
if ($relation === "belongsToMany" or $relation === 'hasMany' or $relation === 'morphMany' or $relation === 'morphToMany') {
|
||||||
|
|||||||
Reference in New Issue
Block a user