/model_annotation

annotate laravel models

Primary LanguagePHP

Model Annotation for Laravel 6

ModelAnnotation puts database schema aside with your model files for easy reference.

Add annotation to plain Laravel model files

<?php
/* MODEL ANNOTATION:
@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

END MODEL ANNOTATION */

namespace App;

use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    /**

Usage

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": {
    ...
    "hpcarlos/model_annotation": "dev-master"
}
.... AND ....
"repositories": {
    ...
    "model_annotation": {
        "type": "vcs",
        "url": "https://github.com/hpcarlos/model_annotation.git"
    }
}
  • Run composer update to install newly added package

  • Add Service Provider in app.php:

'providers' => [
    ....
    hpcarlos\model_annotation\AnnotationServiceProvider::class
]
  • Run php artisan annotate:models to annotate model files