mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-21 03:23:08 +00:00
@@ -58,6 +58,9 @@ Docs are written to a phpfile in the root of the project, so you can move the do
|
|||||||
For now, only models in app/models are scanned. The optional argument tells what models to use.
|
For now, only models in app/models are scanned. The optional argument tells what models to use.
|
||||||
`php artisan ide-helper:models Post,User`
|
`php artisan ide-helper:models Post,User`
|
||||||
|
|
||||||
|
Note: With namespaces, uses \\ instead of \
|
||||||
|
`php artisan ide-helper:models API\\User`
|
||||||
|
|
||||||
This creates a file with the phpDocs for each Model. You should check and change them to be more accurate.
|
This creates a file with the phpDocs for each Model. You should check and change them to be more accurate.
|
||||||
It doesn't know if datetimes are returned as string or DateTime/Carbon, but I assume they are.
|
It doesn't know if datetimes are returned as string or DateTime/Carbon, but I assume they are.
|
||||||
Also, all relations are Eloquent|Eloquent[] by default, you can change them to the actual Model.
|
Also, all relations are Eloquent|Eloquent[] by default, you can change them to the actual Model.
|
||||||
|
|||||||
@@ -105,6 +105,8 @@ class ModelsCommand extends Command {
|
|||||||
}catch(\Exception $e){
|
}catch(\Exception $e){
|
||||||
$this->error("Exception: ".$e->getMessage()."\nCould not analyze class $name.");
|
$this->error("Exception: ".$e->getMessage()."\nCould not analyze class $name.");
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
$this->error("Class $name does not exist");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -240,7 +242,16 @@ class ModelsCommand extends Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function createPhpDocs($class){
|
protected function createPhpDocs($class){
|
||||||
$output = "/**\n *\n * Generated properties for $class\n *\n";
|
|
||||||
|
if(strpos($class, '\\') !== false){
|
||||||
|
$parts = explode('\\', $class);
|
||||||
|
$class = array_pop($parts);
|
||||||
|
$namespace = implode($parts, '\\');
|
||||||
|
}else{
|
||||||
|
$namespace = '';
|
||||||
|
}
|
||||||
|
$output = "namespace $namespace{\n";
|
||||||
|
$output .= "/**\n *\n * Generated properties for $class\n *\n";
|
||||||
foreach($this->properties as $name => $property){
|
foreach($this->properties as $name => $property){
|
||||||
|
|
||||||
if($property['read'] && $property['write']){
|
if($property['read'] && $property['write']){
|
||||||
@@ -253,10 +264,10 @@ class ModelsCommand extends Command {
|
|||||||
$type = $property['type'];
|
$type = $property['type'];
|
||||||
//TODO; check if returned as date
|
//TODO; check if returned as date
|
||||||
|
|
||||||
$output .= " * @$attr $type \$$name \n";
|
$output .= "\t * @$attr $type \$$name \n";
|
||||||
|
|
||||||
}
|
}
|
||||||
$output .= " *\n */\nclass $class {}\n\n";
|
$output .= "\t *\n\t */\n\tclass $class {}\n}\n\n";
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user