Overview

Namespaces

  • None
  • Yajra
    • Oci8
      • Auth
      • Connectors
      • Eloquent
      • Query
        • Grammars
        • Processors
      • Schema
        • Grammars

Classes

  • Yajra\Oci8\Auth\OracleUserProvider
  • Yajra\Oci8\Connectors\OracleConnector
  • Yajra\Oci8\Eloquent\OracleEloquent
  • Yajra\Oci8\Oci8Connection
  • Yajra\Oci8\Oci8ServiceProvider
  • Yajra\Oci8\Query\Grammars\OracleGrammar
  • Yajra\Oci8\Query\OracleBuilder
  • Yajra\Oci8\Query\Processors\OracleProcessor
  • Yajra\Oci8\Schema\Comment
  • Yajra\Oci8\Schema\Grammars\OracleGrammar
  • Yajra\Oci8\Schema\OracleAutoIncrementHelper
  • Yajra\Oci8\Schema\OracleBlueprint
  • Yajra\Oci8\Schema\OracleBuilder
  • Yajra\Oci8\Schema\Sequence
  • Yajra\Oci8\Schema\Trigger

Traits

  • Yajra\Oci8\OracleReservedWords

Functions

  • config_path
  • Overview
  • Namespace
  • Class
  1: <?php
  2: 
  3: namespace Yajra\Oci8\Schema;
  4: 
  5: use Illuminate\Database\Connection;
  6: use Illuminate\Database\Schema\Grammars\Grammar;
  7: use Yajra\Oci8\OracleReservedWords;
  8: 
  9: class Comment extends Grammar
 10: {
 11:     use OracleReservedWords;
 12: 
 13:     /**
 14:      * @var \Illuminate\Database\Connection
 15:      */
 16:     protected $connection;
 17: 
 18:     /**
 19:      * @param Connection $connection
 20:      */
 21:     public function __construct(Connection $connection)
 22:     {
 23:         $this->connection = $connection;
 24:     }
 25: 
 26:     /**
 27:      * Set table and column comments.
 28:      *
 29:      * @param  \Yajra\Oci8\Schema\OracleBlueprint $blueprint
 30:      */
 31:     public function setComments(OracleBlueprint $blueprint)
 32:     {
 33:         // Comment set by $table->comment = 'comment';
 34:         $this->commentTable($blueprint);
 35: 
 36:         // Comments set by $table->string('column')->comment('comment');
 37:         $this->fluentComments($blueprint);
 38: 
 39:         // Comments set by $table->commentColumns = ['column' => 'comment'];
 40:         $this->commentColumns($blueprint);
 41:     }
 42: 
 43:     /**
 44:      * Run the comment on table statement.
 45:      *
 46:      * @param \Yajra\Oci8\Schema\OracleBlueprint $blueprint
 47:      */
 48:     private function commentTable(OracleBlueprint $blueprint)
 49:     {
 50:         $table = $this->wrapValue($blueprint->getTable());
 51: 
 52:         if ($blueprint->comment != null) {
 53:             $this->connection->statement("comment on table {$table} is '{$blueprint->comment}'");
 54:         }
 55:     }
 56: 
 57:     /**
 58:      * Add comments set via fluent setter.
 59:      *
 60:      * @param \Yajra\Oci8\Schema\OracleBlueprint $blueprint
 61:      */
 62:     private function fluentComments(OracleBlueprint $blueprint)
 63:     {
 64:         foreach ($blueprint->getColumns() as $column) {
 65:             if (isset($column['comment'])) {
 66:                 $this->commentColumn($blueprint->getTable(), $column['name'], $column['comment']);
 67:             }
 68:         }
 69:     }
 70: 
 71:     /**
 72:      * Run the comment on column statement
 73:      *
 74:      * @param  string $table
 75:      * @param  string $column
 76:      * @param  string $comment
 77:      */
 78:     private function commentColumn($table, $column, $comment)
 79:     {
 80:         $table = $this->wrapValue($table);
 81: 
 82:         $column = $this->wrapValue($column);
 83: 
 84:         $this->connection->statement("comment on column {$table}.{$column} is '{$comment}'");
 85:     }
 86: 
 87:     /**
 88:      * Add comments on columns.
 89:      *
 90:      * @param \Yajra\Oci8\Schema\OracleBlueprint $blueprint
 91:      */
 92:     private function commentColumns(OracleBlueprint $blueprint)
 93:     {
 94:         foreach ($blueprint->commentColumns as $column => $comment) {
 95:             $this->commentColumn($blueprint->getTable(), $column, $comment);
 96:         }
 97:     }
 98: 
 99:     /**
100:      * Wrap reserved words.
101:      *
102:      * @param string $value
103:      * @return string
104:      */
105:     protected function wrapValue($value)
106:     {
107:         return $this->isReserved($value) ? parent::wrapValue($value) : $value;
108:     }
109: }
110: 
API documentation generated by ApiGen