@@ -34,13 +34,6 @@ class Blueprint
3434 */
3535 protected $ table ;
3636
37- /**
38- * The prefix of the table.
39- *
40- * @var string
41- */
42- protected $ prefix ;
43-
4437 /**
4538 * The columns that should be added to the table.
4639 *
@@ -103,15 +96,13 @@ class Blueprint
10396 * @param \Illuminate\Database\Connection $connection
10497 * @param string $table
10598 * @param \Closure|null $callback
106- * @param string $prefix
10799 * @return void
108100 */
109- public function __construct (Connection $ connection , $ table , ?Closure $ callback = null , $ prefix = '' )
101+ public function __construct (Connection $ connection , $ table , ?Closure $ callback = null )
110102 {
111103 $ this ->connection = $ connection ;
112104 $ this ->grammar = $ connection ->getSchemaGrammar ();
113105 $ this ->table = $ table ;
114- $ this ->prefix = $ prefix ;
115106
116107 if (! is_null ($ callback )) {
117108 $ callback ($ this );
@@ -158,7 +149,7 @@ public function toSql()
158149 $ this ->state ->update ($ command );
159150 }
160151
161- if (! is_null ($ sql = $ this ->grammar ->$ method ($ this , $ command, $ this -> connection ))) {
152+ if (! is_null ($ sql = $ this ->grammar ->$ method ($ this , $ command ))) {
162153 $ statements = array_merge ($ statements , (array ) $ sql );
163154 }
164155 }
@@ -290,7 +281,7 @@ public function addAlterCommands()
290281 return ;
291282 }
292283
293- $ alterCommands = $ this ->grammar ->getAlterCommands ($ this -> connection );
284+ $ alterCommands = $ this ->grammar ->getAlterCommands ();
294285
295286 [$ commands , $ lastCommandWasAlter , $ hasAlterCommand ] = [
296287 [], false , false ,
@@ -313,7 +304,7 @@ public function addAlterCommands()
313304 }
314305
315306 if ($ hasAlterCommand ) {
316- $ this ->state = new BlueprintState ($ this , $ this ->connection , $ this -> grammar );
307+ $ this ->state = new BlueprintState ($ this , $ this ->connection );
317308 }
318309
319310 $ this ->commands = $ commands ;
@@ -1703,9 +1694,13 @@ protected function dropIndexCommand($command, $type, $index)
17031694 */
17041695 protected function createIndexName ($ type , array $ columns )
17051696 {
1706- $ table = str_contains ($ this ->table , '. ' )
1707- ? substr_replace ($ this ->table , '. ' .$ this ->prefix , strrpos ($ this ->table , '. ' ), 1 )
1708- : $ this ->prefix .$ this ->table ;
1697+ $ table = $ this ->table ;
1698+
1699+ if ($ this ->connection ->getConfig ('prefix_indexes ' )) {
1700+ $ table = str_contains ($ this ->table , '. ' )
1701+ ? substr_replace ($ this ->table , '. ' .$ this ->connection ->getTablePrefix (), strrpos ($ this ->table , '. ' ), 1 )
1702+ : $ this ->connection ->getTablePrefix ().$ this ->table ;
1703+ }
17091704
17101705 $ index = strtolower ($ table .'_ ' .implode ('_ ' , $ columns ).'_ ' .$ type );
17111706
@@ -1824,11 +1819,13 @@ public function getTable()
18241819 /**
18251820 * Get the table prefix.
18261821 *
1822+ * @deprecated Use DB::getTablePrefix()
1823+ *
18271824 * @return string
18281825 */
18291826 public function getPrefix ()
18301827 {
1831- return $ this ->prefix ;
1828+ return $ this ->connection -> getTablePrefix () ;
18321829 }
18331830
18341831 /**
@@ -1854,7 +1851,6 @@ public function getCommands()
18541851 /**
18551852 * Determine if the blueprint has state.
18561853 *
1857- * @param mixed $name
18581854 * @return bool
18591855 */
18601856 private function hasState (): bool
0 commit comments