1: <?php
2:
3: namespace Yajra\Oci8\Schema;
4:
5: use Closure;
6: use Illuminate\Database\Connection;
7: use Illuminate\Database\Schema\Builder;
8:
9: class OracleBuilder extends Builder
10: {
11: 12: 13:
14: public $helper;
15:
16: 17: 18:
19: public $comment;
20:
21: 22: 23:
24: public function __construct(Connection $connection)
25: {
26: $this->connection = $connection;
27: $this->grammar = $connection->getSchemaGrammar();
28: $this->helper = new OracleAutoIncrementHelper($connection);
29: $this->comment = new Comment($connection);
30: }
31:
32: 33: 34: 35: 36: 37: 38:
39: public function create($table, Closure $callback)
40: {
41: $blueprint = $this->createBlueprint($table);
42:
43: $blueprint->create();
44:
45: $callback($blueprint);
46:
47: $this->build($blueprint);
48:
49: $this->comment->setComments($blueprint);
50:
51: $this->helper->createAutoIncrementObjects($blueprint, $table);
52: }
53:
54: 55: 56: 57: 58: 59: 60:
61: public function table($table, Closure $callback)
62: {
63: $blueprint = $this->createBlueprint($table);
64:
65: $callback($blueprint);
66:
67: foreach($blueprint->getCommands() as $command)
68: {
69: if ($command->get('name') == 'drop')
70: {
71: $this->helper->dropAutoIncrementObjects($table);
72: }
73: }
74:
75: $this->build($blueprint);
76:
77: $this->comment->setComments($blueprint);
78: }
79:
80: 81: 82: 83: 84: 85: 86:
87: protected function createBlueprint($table, Closure $callback = null)
88: {
89: $blueprint = new OracleBlueprint($table, $callback);
90: $blueprint->setTablePrefix($this->connection->getTablePrefix());
91:
92: return $blueprint;
93: }
94:
95: 96: 97: 98: 99: 100:
101: public function drop($table)
102: {
103: $this->helper->dropAutoIncrementObjects($table);
104: parent::drop($table);
105: }
106:
107: 108: 109: 110: 111:
112: public function dropIfExists($table)
113: {
114: $this->helper->dropAutoIncrementObjects($table);
115: parent::dropIfExists($table);
116: }
117: }
118: