mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 01:57:13 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f77f5ae770 | ||
|
|
82ffa52d79 | ||
|
|
d8ed55be7a | ||
|
|
16f77638f1 | ||
|
|
348ecb361c |
@@ -193,23 +193,25 @@ class GeneratorCommand extends Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($output as $ns => $body){
|
|
||||||
if ($ns == '__root') $ns = '';
|
|
||||||
$outputString .= "namespace $ns{\n";
|
|
||||||
$outputString .= $body;
|
|
||||||
$outputString .= "}\n\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
//Include the helper file, if requested
|
//Include the helper file, if requested
|
||||||
if(!empty($this->helpers)){
|
if(!empty($this->helpers)){
|
||||||
foreach($this->helpers as $helper){
|
foreach($this->helpers as $helper){
|
||||||
if (file_exists($helper)){
|
if (file_exists($helper)){
|
||||||
$output .= str_replace(array('<?php', '?>'), '', \File::get($helper));
|
$output['__root'] .= str_replace(array('<?php', '?>'), '', \File::get($helper));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($output as $ns => $body){
|
||||||
|
if ($ns == '__root'){
|
||||||
|
$ns = '';
|
||||||
|
}
|
||||||
|
$outputString .= "namespace $ns{\n";
|
||||||
|
$outputString .= $body;
|
||||||
|
$outputString .= "}\n\n";
|
||||||
|
}
|
||||||
|
|
||||||
return $outputString;
|
return $outputString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -237,7 +237,7 @@ class ModelsCommand extends Command {
|
|||||||
|
|
||||||
|
|
||||||
$this->setProperty($name, $type, true, true);
|
$this->setProperty($name, $type, true, true);
|
||||||
$this->setMethod(Str::camel("where_".$name), '\Illuminate\Database\Query\Builder|\\'.get_class($model), array('$value'));
|
//$this->setMethod(Str::camel("where_".$name), '\Illuminate\Database\Query\Builder|\\'.get_class($model), array('$value'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -287,14 +287,14 @@ class ModelsCommand extends Command {
|
|||||||
$begin = strpos($code, 'function(');
|
$begin = strpos($code, 'function(');
|
||||||
$code = substr($code, $begin, strrpos($code, '}') - $begin + 1);
|
$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.'(';
|
$search = '$this->'.$relation.'(';
|
||||||
if($pos = stripos($code, $search)){
|
if($pos = stripos($code, $search)){
|
||||||
$code = substr($code, $pos + strlen($search));
|
$code = substr($code, $pos + strlen($search));
|
||||||
$arguments = explode(',', substr($code, 0, stripos($code, ')')));
|
$arguments = explode(',', substr($code, 0, stripos($code, ')')));
|
||||||
//Remove quotes, ensure 1 \ in front of the model
|
//Remove quotes, ensure 1 \ in front of the model
|
||||||
$returnModel = "\\".ltrim(trim($arguments[0], " \"'"), "\\");
|
$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)
|
//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{
|
||||||
|
|||||||
Reference in New Issue
Block a user