mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 18:13:11 +00:00
@@ -11,6 +11,7 @@
|
|||||||
namespace Barryvdh\LaravelIdeHelper\Console;
|
namespace Barryvdh\LaravelIdeHelper\Console;
|
||||||
|
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\Relation;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Illuminate\Filesystem\Filesystem;
|
use Illuminate\Filesystem\Filesystem;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
@@ -364,13 +365,14 @@ class ModelsCommand extends Command
|
|||||||
) as $relation) {
|
) as $relation) {
|
||||||
$search = '$this->' . $relation . '(';
|
$search = '$this->' . $relation . '(';
|
||||||
if ($pos = stripos($code, $search)) {
|
if ($pos = stripos($code, $search)) {
|
||||||
$code = substr($code, $pos + strlen($search));
|
|
||||||
$end = strpos($code, ')->') ?:strpos($code, ');');
|
|
||||||
if (false !== $end) {
|
|
||||||
//Resolve the relation's model to a fully-qualified class name.
|
|
||||||
$relatedModel = '\\' . get_class($model->$method()->getRelated());
|
|
||||||
|
|
||||||
if ($relation === "belongsToMany" or $relation === 'hasMany' or $relation === 'morphMany' or $relation === 'morphToMany') {
|
//Resolve the relation's model to a Relation object.
|
||||||
|
$relationObj = $model->$method();
|
||||||
|
|
||||||
|
if ($relationObj instanceof Relation) {
|
||||||
|
$relatedModel = '\\' . get_class($relationObj->getRelated());
|
||||||
|
|
||||||
|
if (in_array($relation, ['belongsToMany', 'hasMany', 'morphMany', 'morphToMany'])) {
|
||||||
//Collection or array of models (because Collection is Arrayable)
|
//Collection or array of models (because Collection is Arrayable)
|
||||||
$this->setProperty(
|
$this->setProperty(
|
||||||
$method,
|
$method,
|
||||||
|
|||||||
Reference in New Issue
Block a user