From d8ed55be7ab4a371a0718104c4315b8d1c400e11 Mon Sep 17 00:00:00 2001 From: Ulrich Kautz Date: Tue, 22 Apr 2014 14:25:44 +0200 Subject: [PATCH] Added property methods for polymorphic relations --- src/Barryvdh/LaravelIdeHelper/ModelsCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Barryvdh/LaravelIdeHelper/ModelsCommand.php b/src/Barryvdh/LaravelIdeHelper/ModelsCommand.php index e2ee119..801cdf0 100644 --- a/src/Barryvdh/LaravelIdeHelper/ModelsCommand.php +++ b/src/Barryvdh/LaravelIdeHelper/ModelsCommand.php @@ -287,14 +287,14 @@ class ModelsCommand extends Command { $begin = strpos($code, 'function('); $code = substr($code, $begin, strrpos($code, '}') - $begin + 1); - foreach(array('hasMany', 'belongsToMany', 'hasOne', 'belongsTo') as $relation){ + foreach(array('hasMany', 'belongsToMany', 'hasOne', 'belongsTo', 'morphTo', 'morphMany', 'morphToMany') as $relation){ $search = '$this->'.$relation.'('; if($pos = stripos($code, $search)){ $code = substr($code, $pos + strlen($search)); $arguments = explode(',', substr($code, 0, stripos($code, ')'))); //Remove quotes, ensure 1 \ in front of the model $returnModel = "\\".ltrim(trim($arguments[0], " \"'"), "\\"); - if($relation === "belongsToMany" or $relation === 'hasMany'){ + if($relation === "belongsToMany" or $relation === 'hasMany' or $relation === 'morphMany' or $relation === 'morphToMany'){ //Collection or array of models (because Collection is Arrayable) $this->setProperty($method, '\Illuminate\Database\Eloquent\Collection|'.$returnModel.'[]', true, null); }else{