@@ -20,32 +20,30 @@ class Migration{
2020 /**
2121 * constructor.
2222 */
23- public function __construct ($ connection = null )
23+ public function __construct ()
2424 {
2525 self ::$ error = Constant::STATUS_400 ;
2626 }
2727
2828 /**
2929 * Create migration name
30- * @param string $table_name
30+ * @param string $table
3131 * @param string|null $type
3232 * - [optional] <jobs, sessions> create schema with dummy Data
3333 *
3434 * @return \Tamedevelopers\Support\Collections\Collection
3535 */
36- public static function create ($ table_name , $ type = null )
36+ public static function create ($ table , $ type = null )
3737 {
3838 self ::normalizeFolderStructure ();
3939
4040 self ::initBaseDirectory ();
4141
42- return self ::runMigrationCreateTable ($ table_name , $ type );
42+ return self ::runMigrationCreateTable ($ table , $ type );
4343 }
4444
4545 /**
4646 * Staring our migration
47- * @param string $type
48- * @param string $column
4947 *
5048 * @return \Tamedevelopers\Support\Collections\Collection
5149 */
@@ -94,10 +92,10 @@ public static function run()
9492
9593 /**
9694 * Run the migrations.
97- *
98- * @return mixed
95+ * @return null
9996 */
100- public function up (){
97+ public function up ()
98+ {
10199 return null ;
102100 }
103101
@@ -125,14 +123,26 @@ public function drop($force = false)
125123 foreach ($ files as $ file ){
126124 $ migration = include_once "{$ file }" ;
127125
128- // error
126+ // call drop on the migration class; it may not return anything (void)
129127 $ handle = $ migration ->drop ($ force );
130128
131- // store all messages
132- $ errorMessage [] = $ handle ['message ' ];
129+ // normalize possible return types
130+ if ($ handle instanceof Collection) {
131+ $ handle = $ handle ->toArray ();
132+ }
133+
134+ // If migration didn't return a result, fallback to last Schema result
135+ if (!is_array ($ handle )) {
136+ $ handle = Schema::getLastResult ();
137+ }
138+
139+ // store all messages, if available
140+ if (is_array ($ handle ) && isset ($ handle ['message ' ])) {
141+ $ errorMessage [] = $ handle ['message ' ];
142+ }
133143
134144 // error occured stop code execution
135- if ( $ handle ['status ' ] != Constant::STATUS_200 ){
145+ if ( is_array ( $ handle) && isset ( $ handle ['status ' ]) && $ handle [ ' status ' ] != Constant::STATUS_200 ) {
136146 $ errorstatus = $ handle ['status ' ];
137147 break ;
138148 }
0 commit comments