项目作者: diplodocker

项目描述 :
💬Table comments loader for Laravel
高级语言: PHP
项目地址: git://github.com/diplodocker/comments-loader.git
创建时间: 2019-03-07T19:55:54Z
项目社区:https://github.com/diplodocker/comments-loader

开源协议:MIT License

下载


Laravel table comments loader

Header

Build Status
Made for Laravel
PHP from Packagist

Why should I use a package?

Because

Install

  • Install laravel =)
  • composer require --dev diplodocker/comments-loader

Lumen provider setup

bootstrap/app.php

  1. $app->register(Diplodocker\Providers\CommentsLoaderProvider::class);

Usage in migration (MySQL or Postgres)

  1. /**
  2. * Run the migrations.
  3. *
  4. * @return void
  5. */
  6. public function up()
  7. {
  8. Schema::create('test', function (Blueprint $table) {
  9. $table->bigIncrements('id');
  10. $table->nullableTimestamps();
  11. $table->tableComment('its sample table comment');
  12. });
  13. // or change on existing table
  14. Schema::table('test', function(Blueprint $table) {
  15. $table->tableComment('its changed comment');
  16. });
  17. }

Or use class (only for MySQL)

  1. <?php
  2. use Diplodocker\CommentsLoaderMigration;
  3. class SomeMigrationFileName extends CommentsLoaderMigration
  4. {
  5. public $comments = [
  6. 'users' => 'Users table',
  7. 'documents' => 'Documents table',
  8. ...
  9. ];

Or use trait

  1. <?php
  2. use Diplodocker\Concerns\CommentsLoader;
  3. use Illuminate\Database\Migrations\Migration;
  4. class SomeMigrationFileName extends Migration
  5. {
  6. // use trait
  7. use CommentsLoader;
  8. public $comments = [
  9. 'users' => 'Users table',
  10. 'documents' => 'Documents table',
  11. ...
  12. ];
  13. /**
  14. * Run the migrations.
  15. *
  16. * @return void
  17. */
  18. public function up()
  19. {
  20. // your code here
  21. $this->loadTableComments();
  22. }
  23. /**
  24. * Reverse the migrations.
  25. *
  26. * @return void
  27. */
  28. public function down()
  29. {
  30. // your code here
  31. }