bastinald / laravel-automatic-migrations

Automatic Laravel model migrations.
42 stars 11 forks source link

Extract paths to constant or variables #2

Closed codebjorn closed 3 years ago

codebjorn commented 3 years ago

https://github.com/bastinald/laravel-automatic-migrations/blob/31d26e9ab35e41d25692524fd32b8ff92f7959fc/src/Providers/LaravelAutomaticMigrationsProvider.php#L23

First hi, I want to say that is very interesting project. Here on publish I see that multiple times are used same paths:

'/../../config'
'/../../resources'

As a purpose maybe will be better to extract them to variables or constants(if will be used on other classes), as example:

$configPath = __DIR__ . '/../../config';
$resourcesPath = __DIR__ . '/../../resources';

or in class

const CONFIG_PATH = __DIR__ . '/../../config';
const RESOURCES_PATH = __DIR__ . '/../../resources';

and usage will be

 $this->publishes(
            ["{$configPath}/laravel-automatic-migrations.php" => config_path('laravel-automatic-migrations.php')],
 ...

or

 $this->publishes(
            [CONFIG_PATH  . '/laravel-automatic-migrations.php' => config_path('laravel-automatic-migrations.php')],
 ...
bastinald commented 3 years ago

Those strings are only used once inside the service provider to tell Laravel where to publish the files if someone chooses to do so via the vendor:publish command.