for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace LaTevaWeb\Translatable;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Collection;
use Illuminate\Support\ServiceProvider;
class TranslatableServiceProvider extends ServiceProvider
{
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = false;
* Bootstrap services.
* @return void
public function boot(Filesystem $filesystem)
$this->publishes([
__DIR__.'/../config/latevaweb-translatable.php' => config_path('latevaweb-translatable.php'),
], 'config');
__DIR__.'/../database/migrations/create_translations_tables.php.stub' => $this->getMigrationFileName($filesystem),
], 'migrations');
}
* Register the service provider.
public function register()
$this->mergeConfigFrom(
__DIR__.'/../config/latevaweb-translatable.php',
'latevaweb-translatable'
);
* Returns existing migration file if found, else uses the current timestamp.
* @param Filesystem $filesystem
* @return string
protected function getMigrationFileName(Filesystem $filesystem): string
$timestamp = date('Y_m_d_His');
return Collection::make($this->app->databasePath().DIRECTORY_SEPARATOR.'migrations'.DIRECTORY_SEPARATOR)
->flatMap(function ($path) use ($filesystem) {
return $filesystem->glob($path.'*_create_robots_tables.php');
})
->push($this->app->databasePath()."/migrations/{$timestamp}_create_robots_tables.php")
->first();