mirror of
https://github.com/openclassify/openclassify.git
synced 2026-04-14 11:12:09 -05:00
- Complete rewrite using Laravel 12 framework - Modular architecture with nwidart/laravel-modules v11 - Modules: Category, Listing, Location, Profile - 8 top-level categories with 33 subcategories seeded - 6 sample listings seeded - 5 countries, 13 cities, districts seeded - Multi-language support: en, tr, ar, zh, es, fr, de, pt, ru, ja - Auth scaffolding via Laravel Breeze - Partner dashboard for user listing management - Tailwind CSS via CDN for styling - SQLite database for development - RTL support for Arabic locale Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
136 lines
4.0 KiB
Plaintext
136 lines
4.0 KiB
Plaintext
<?php
|
|
|
|
namespace $NAMESPACE$;
|
|
|
|
use Illuminate\Support\Facades\Blade;
|
|
use Illuminate\Support\ServiceProvider;
|
|
use Nwidart\Modules\Traits\PathNamespace;
|
|
use RecursiveDirectoryIterator;
|
|
use RecursiveIteratorIterator;
|
|
|
|
class $CLASS$ extends ServiceProvider
|
|
{
|
|
use PathNamespace;
|
|
|
|
protected string $name = '$MODULE$';
|
|
|
|
protected string $nameLower = '$LOWER_NAME$';
|
|
|
|
/**
|
|
* Boot the application events.
|
|
*/
|
|
public function boot(): void
|
|
{
|
|
$this->registerCommands();
|
|
$this->registerCommandSchedules();
|
|
$this->registerTranslations();
|
|
$this->registerConfig();
|
|
$this->registerViews();
|
|
$this->loadMigrationsFrom(module_path($this->name, '$MIGRATIONS_PATH$'));
|
|
}
|
|
|
|
/**
|
|
* Register the service provider.
|
|
*/
|
|
public function register(): void
|
|
{
|
|
$this->app->register(EventServiceProvider::class);
|
|
$this->app->register(RouteServiceProvider::class);
|
|
}
|
|
|
|
/**
|
|
* Register commands in the format of Command::class
|
|
*/
|
|
protected function registerCommands(): void
|
|
{
|
|
// $this->commands([]);
|
|
}
|
|
|
|
/**
|
|
* Register command Schedules.
|
|
*/
|
|
protected function registerCommandSchedules(): void
|
|
{
|
|
// $this->app->booted(function () {
|
|
// $schedule = $this->app->make(Schedule::class);
|
|
// $schedule->command('inspire')->hourly();
|
|
// });
|
|
}
|
|
|
|
/**
|
|
* Register translations.
|
|
*/
|
|
public function registerTranslations(): void
|
|
{
|
|
$langPath = resource_path('lang/modules/'.$this->nameLower);
|
|
|
|
if (is_dir($langPath)) {
|
|
$this->loadTranslationsFrom($langPath, $this->nameLower);
|
|
$this->loadJsonTranslationsFrom($langPath);
|
|
} else {
|
|
$this->loadTranslationsFrom(module_path($this->name, '$PATH_LANG$'), $this->nameLower);
|
|
$this->loadJsonTranslationsFrom(module_path($this->name, '$PATH_LANG$'));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Register config.
|
|
*/
|
|
protected function registerConfig(): void
|
|
{
|
|
$relativeConfigPath = config('modules.paths.generator.config.path');
|
|
$configPath = module_path($this->name, $relativeConfigPath);
|
|
|
|
if (is_dir($configPath)) {
|
|
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($configPath));
|
|
|
|
foreach ($iterator as $file) {
|
|
if ($file->isFile() && $file->getExtension() === 'php') {
|
|
$relativePath = str_replace($configPath . DIRECTORY_SEPARATOR, '', $file->getPathname());
|
|
$configKey = $this->nameLower . '.' . str_replace([DIRECTORY_SEPARATOR, '.php'], ['.', ''], $relativePath);
|
|
$key = ($relativePath === 'config.php') ? $this->nameLower : $configKey;
|
|
|
|
$this->publishes([$file->getPathname() => config_path($relativePath)], 'config');
|
|
$this->mergeConfigFrom($file->getPathname(), $key);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Register views.
|
|
*/
|
|
public function registerViews(): void
|
|
{
|
|
$viewPath = resource_path('views/modules/'.$this->nameLower);
|
|
$sourcePath = module_path($this->name, '$PATH_VIEWS$');
|
|
|
|
$this->publishes([$sourcePath => $viewPath], ['views', $this->nameLower.'-module-views']);
|
|
|
|
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->nameLower);
|
|
|
|
$componentNamespace = $this->module_namespace($this->name, $this->app_path(config('modules.paths.generator.component-class.path')));
|
|
Blade::componentNamespace($componentNamespace, $this->nameLower);
|
|
}
|
|
|
|
/**
|
|
* Get the services provided by the provider.
|
|
*/
|
|
public function provides(): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
private function getPublishableViewPaths(): array
|
|
{
|
|
$paths = [];
|
|
foreach (config('view.paths') as $path) {
|
|
if (is_dir($path.'/modules/'.$this->nameLower)) {
|
|
$paths[] = $path.'/modules/'.$this->nameLower;
|
|
}
|
|
}
|
|
|
|
return $paths;
|
|
}
|
|
}
|