diplodocker/comments-loader

Laravel table comments loader (part of Diplodocker project)

Fund package maintenance!
Patreon

0.0.2 2022-10-11 13:12 UTC

This package is auto-updated.

Last update: 2024-04-11 17:21:47 UTC


README

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

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

Usage in migration (MySQL or Postgres)

/**
 * Run the migrations.
 *
 * @return void
 */
public function up()
{
    Schema::create('test', function (Blueprint $table) {
        $table->bigIncrements('id');
        $table->nullableTimestamps();
        $table->tableComment('its sample table comment');
    });
    
    // or change on existing table
    Schema::table('test', function(Blueprint $table) {
        $table->tableComment('its changed comment');
    });
}

Or use class (only for MySQL)

<?php

use Diplodocker\CommentsLoaderMigration;

class SomeMigrationFileName extends CommentsLoaderMigration
{
    public $comments = [
        'users' => 'Users table',
        'documents' => 'Documents table',
        ...
    ];

Or use trait

<?php

use Diplodocker\Concerns\CommentsLoader;
use Illuminate\Database\Migrations\Migration;

class SomeMigrationFileName extends Migration
{
    // use trait
    use CommentsLoader;

    public $comments = [
        'users' => 'Users table',
        'documents' => 'Documents table',
        ...
    ];

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        // your code here
        $this->loadTableComments();
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        // your code here
    }