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:
Barry vd. Heuvel
2013-05-07 15:15:27 -07:00
@@ -199,7 +199,10 @@ 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
if (isset($parts[2]))
{
list($relation, $returnModel, $rest) = $parts;
$relation = trim($relation, ' ('); $relation = trim($relation, ' (');
if($relation === "belongsTo" or $relation === 'hasOne'){ if($relation === "belongsTo" or $relation === 'hasOne'){
@@ -208,6 +211,7 @@ class ModelsCommand extends Command {
}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
} }