File tree Expand file tree Collapse file tree 2 files changed +13
-8
lines changed Expand file tree Collapse file tree 2 files changed +13
-8
lines changed Original file line number Diff line number Diff line change 77
88class Sync extends Command
99{
10- protected $ signature = 'data:sync {--path=} ' ;
10+ protected $ signature = 'data:sync {--path=} {--model=} ' ;
1111
1212 protected $ description = 'Update Models with respective sync data files ' ;
1313
1414 public function handle ()
1515 {
1616 $ path = $ this ->option ('path ' );
17+ $ model = $ this ->option ('model ' );
1718
1819 $ this ->info ('Updating Models with sync data files ' );
19- (new Updater ($ path ))->run ();
20+
21+ (new Updater ($ path , $ model ))->run ();
22+
2023 $ this ->comment ('Data sync completed ' );
2124 }
2225}
Original file line number Diff line number Diff line change @@ -13,12 +13,10 @@ class Updater
1313 *
1414 * @param string|null $path
1515 */
16- public function __construct ($ path = null )
16+ public function __construct ($ path = null , $ model = null )
1717 {
18-
19- $ this ->files = $ this ->getFiles (
20- $ this ->getDirectory ($ path )
21- );
18+ $ directory = $ this ->getDirectory ($ path );
19+ $ this ->files = $ this ->getFiles ($ directory , $ model );
2220 }
2321
2422 /**
@@ -84,8 +82,12 @@ protected function getDirectory($path)
8482 * @param string $directory
8583 * @return void
8684 */
87- protected function getFiles (string $ directory )
85+ protected function getFiles (string $ directory, string $ model )
8886 {
87+ if ($ model ) {
88+ return $ directory . '/ ' . $ model . '.json ' ;
89+ }
90+
8991 return collect (File::files ($ directory ))->map (function ($ path ) {
9092 return $ path ->getPathname ();
9193 })->toArray ();
You can’t perform that action at this time.
0 commit comments