ModelAnnotation puts database schema aside with your model files for easy reference.
Add PHPDoc annotation to plain Laravel model files
/**
* AUTOMATICALLY GENERATED BY fjf2002\ModelAnnotation
*
* Class User
*
* @property int $id Type: int(10) unsigned, Extra: auto_increment, Default: null, Key: PRI
* @property string $name Type: varchar(255), Extra: , Default: null, Key: nil
* @property string $email Type: varchar(255), Extra: , Default: null, Key: UNI
* @property string $password Type: varchar(60), Extra: , Default: null, Key: nil
* @property string|null $remember_token Type: varchar(100), Extra: , Default: null, Key: nil
* @property int|null $created_at Type: timestamp, Extra: , Default: null, Key: nil
* @property int|null $updated_at Type: timestamp, Extra: , Default: null, Key: nil
*/
class User extends Model {
// etc.
This package is forked from qsum/ModelAnnotation, with two major changes:
-
The Model classes are crawled (instead of the tables) and $model->getTable() is considered to find the corresponding table
-
PHPDoc-style comments are generated.
This package only works with MySQL for now.
-
Make sure you have backup or VCS.
-
Modify composer.json file, include following line for
require
section:
"require-dev": {
...
"hpcarlos/model_annotation": "dev-master",
}
...
"repositories": {
"model_annotation": {
"type": "vcs",
"url": "https://github.com/hpcarlos/model-annotation-mysql.git"
}
},
-
Run
composer update
to install newly added package -
Add
Service Provider
inapp.php
:
'providers' => [
....
fjf2002\ModelAnnotation\AnnotationServiceProvider::class
]
- Run
php artisan annotate:models
to annotate model files