mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 01:57:13 +00:00
Merge pull request #10 from awellis13/patch-1
fixed a bug causing the model command to fail on methods that are not re...
This commit is contained in:
@@ -199,15 +199,19 @@ class ModelsCommand extends Command {
|
|||||||
$code = substr($code, $begin, strrpos($code, '}') - $begin + 1);
|
$code = substr($code, $begin, strrpos($code, '}') - $begin + 1);
|
||||||
|
|
||||||
$begin = stripos($code, 'return $this->');
|
$begin = stripos($code, 'return $this->');
|
||||||
list($relation, $returnModel, $rest) = explode("'", substr($code, $begin+14),3); //"return $this->" is 14 chars
|
$parts = explode("'", substr($code, $begin+14),3); //"return $this->" is 14 chars
|
||||||
$relation = trim($relation, ' (');
|
if (isset($parts[2]))
|
||||||
|
{
|
||||||
|
list($relation, $returnModel, $rest) = $parts;
|
||||||
|
$relation = trim($relation, ' (');
|
||||||
|
|
||||||
if($relation === "belongsTo" or $relation === 'hasOne'){
|
if($relation === "belongsTo" or $relation === 'hasOne'){
|
||||||
//Single model is returned
|
//Single model is returned
|
||||||
$this->setProperty($method, $returnModel, true, null);
|
$this->setProperty($method, $returnModel, true, null);
|
||||||
}elseif($relation === "belongsToMany" or $relation === 'hasMany'){
|
}elseif($relation === "belongsToMany" or $relation === 'hasMany'){
|
||||||
//Collection or array of models (because Collection is Arrayable)
|
//Collection or array of models (because Collection is Arrayable)
|
||||||
$this->setProperty($method, '\Illuminate\Database\Eloquent\Collection|'.$returnModel.'[]', true, null);
|
$this->setProperty($method, '\Illuminate\Database\Eloquent\Collection|'.$returnModel.'[]', true, null);
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
//Not a relation
|
//Not a relation
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user