mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-22 20:13:08 +00:00
@@ -11,6 +11,7 @@
|
||||
namespace Barryvdh\LaravelIdeHelper\Console;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\Eloquent\Relations\Relation;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
@@ -364,13 +365,14 @@ class ModelsCommand extends Command
|
||||
) as $relation) {
|
||||
$search = '$this->' . $relation . '(';
|
||||
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)
|
||||
$this->setProperty(
|
||||
$method,
|
||||
|
||||
Reference in New Issue
Block a user