@@ -74,8 +74,8 @@ public function __construct(
7474 Container $ laravel ,
7575 DatabaseMigrationRepository $ repository ,
7676 Resolver $ resolver ,
77- Filesystem $ files)
78- {
77+ Filesystem $ files
78+ ) {
7979 $ this ->laravel = $ laravel ;
8080 $ this ->files = $ files ;
8181 $ this ->resolver = $ resolver ;
@@ -116,9 +116,7 @@ public function run($paths = [], array $options = [])
116116 // run each of the outstanding migrations against a database connection.
117117 $ files = $ this ->getCommandFiles ($ paths );
118118
119- $ this ->requireFiles ($ migrations = $ this ->pendingMigrations (
120- $ files , $ this ->repository ->getRan ()
121- ));
119+ $ migrations = $ this ->requirePendingMigrations ($ files );
122120
123121 // Once we have all these migrations that are outstanding we are ready to run
124122 // we will go ahead and run them "up". This will execute each migration as
@@ -128,11 +126,53 @@ public function run($paths = [], array $options = [])
128126 return $ migrations ;
129127 }
130128
129+ /**
130+ * @param array $paths
131+ * @param array $options
132+ * @return array
133+ */
134+ public function markAllCompleted ($ paths = [], array $ options = [])
135+ {
136+ $ files = $ this ->getCommandFiles ($ paths );
137+
138+ $ migrations = $ this ->requirePendingMigrations ($ files );
139+
140+ foreach ($ migrations as $ file ) {
141+ $ this ->markFileCompleted ($ file );
142+ }
143+
144+ $ this ->note ("<info>Marked all pending commands as completed</info> " );
145+
146+ return $ migrations ;
147+ }
148+
149+ /**
150+ * @param string $file
151+ * @return void
152+ */
153+ protected function markFileCompleted ($ file )
154+ {
155+ $ name = $ this ->getCommandName ($ file );
156+ $ this ->repository ->log ($ name );
157+ }
158+
159+ /**
160+ * @param array $files
161+ * @return array
162+ */
163+ protected function requirePendingMigrations (array $ files = [])
164+ {
165+ $ this ->requireFiles ($ migrations = $ this ->pendingMigrations (
166+ $ files , $ this ->repository ->getRan ()
167+ ));
168+ return $ migrations ;
169+ }
170+
131171 /**
132172 * Get the migration files that have not yet run.
133173 *
134- * @param array $files
135- * @param array $ran
174+ * @param array $files
175+ * @param array $ran
136176 * @return array
137177 */
138178 protected function pendingMigrations ($ files , $ ran )
@@ -211,8 +251,8 @@ protected function runCommand($file, $pretend)
211251 /**
212252 * Pretend to run the migrations.
213253 *
214- * @param object|Command $command
215- * @param string $method
254+ * @param object|Command $command
255+ * @param string $method
216256 * @return void
217257 */
218258 protected function pretendToRun ($ command , $ method )
@@ -227,8 +267,8 @@ protected function pretendToRun($command, $method)
227267 /**
228268 * Get all of the queries that would be run for a migration.
229269 *
230- * @param object|Command $command
231- * @param string $method
270+ * @param object|Command $command
271+ * @param string $method
232272 * @return array
233273 */
234274 protected function getQueries ($ command , $ method )
@@ -248,7 +288,7 @@ protected function getQueries($command, $method)
248288 /**
249289 * Resolve a migration instance from a file.
250290 *
251- * @param string $file
291+ * @param string $file
252292 * @return object|Command
253293 */
254294 public function resolve ($ file )
@@ -265,13 +305,13 @@ public function resolve($file)
265305 /**
266306 * Get all of the migration files in a given path.
267307 *
268- * @param string|array $paths
308+ * @param string|array $paths
269309 * @return array
270310 */
271311 public function getCommandFiles ($ paths )
272312 {
273313 return Collection::make ($ paths )->flatMap (function ($ path ) {
274- return $ this ->files ->glob ($ path. '/*_*.php ' );
314+ return $ this ->files ->glob ($ path . '/*_*.php ' );
275315 })->filter ()->sortBy (function ($ file ) {
276316 return $ this ->getCommandName ($ file );
277317 })->values ()->keyBy (function ($ file ) {
@@ -282,7 +322,7 @@ public function getCommandFiles($paths)
282322 /**
283323 * Require in all the migration files in a given path.
284324 *
285- * @param array $files
325+ * @param array $files
286326 * @return void
287327 */
288328 public function requireFiles (array $ files )
@@ -295,7 +335,7 @@ public function requireFiles(array $files)
295335 /**
296336 * Get the name of the migration.
297337 *
298- * @param string $path
338+ * @param string $path
299339 * @return string
300340 */
301341 public function getCommandName ($ path )
@@ -306,7 +346,7 @@ public function getCommandName($path)
306346 /**
307347 * Register a custom migration path.
308348 *
309- * @param string $path
349+ * @param string $path
310350 * @return void
311351 */
312352 public function path ($ path )
@@ -327,12 +367,12 @@ public function paths()
327367 /**
328368 * Set the default connection name.
329369 *
330- * @param string $name
370+ * @param string $name
331371 * @return void
332372 */
333373 public function setConnection ($ name )
334374 {
335- if (! is_null ($ name )) {
375+ if (!is_null ($ name )) {
336376 $ this ->resolver ->setDefaultConnection ($ name );
337377 }
338378
@@ -344,7 +384,7 @@ public function setConnection($name)
344384 /**
345385 * Resolve the database connection instance.
346386 *
347- * @param string $connection
387+ * @param string $connection
348388 * @return \Illuminate\Database\Connection
349389 */
350390 public function resolveConnection ($ connection )
@@ -355,7 +395,7 @@ public function resolveConnection($connection)
355395 /**
356396 * Get the schema grammar out of a migration connection.
357397 *
358- * @param \Illuminate\Database\Connection $connection
398+ * @param \Illuminate\Database\Connection $connection
359399 * @return \Illuminate\Database\Schema\Grammars\Grammar
360400 */
361401 protected function getSchemaGrammar ($ connection )
@@ -402,7 +442,7 @@ public function getFilesystem()
402442 /**
403443 * Raise a note event for the migrator.
404444 *
405- * @param string $message
445+ * @param string $message
406446 * @return void
407447 */
408448 protected function note ($ message )
0 commit comments