Skip to content

Commit

Permalink
Release 2024.4
Browse files Browse the repository at this point in the history
  • Loading branch information
dedanirungu committed Sep 3, 2024
1 parent 6369f84 commit 27af335
Show file tree
Hide file tree
Showing 11 changed files with 288 additions and 2 deletions.
29 changes: 29 additions & 0 deletions app/Filament/Clusters/Sale.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Modules\Sale\Filament\Clusters;

use Filament\Clusters\Cluster;
use Nwidart\Modules\Facades\Module;

class Sale extends Cluster
{
public static function getModuleName(): string
{
return 'Sale';
}

public static function getModule(): \Nwidart\Modules\Module
{
return Module::findOrFail(static::getModuleName());
}

public static function getNavigationLabel(): string
{
return __('Sale');
}

public static function getNavigationIcon(): ?string
{
return 'heroicon-o-squares-2x2';
}
}
27 changes: 27 additions & 0 deletions app/Filament/SalePlugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Modules\Sale\Filament;

use Coolsam\Modules\Concerns\ModuleFilamentPlugin;
use Filament\Contracts\Plugin;
use Filament\Panel;

class SalePlugin implements Plugin
{
use ModuleFilamentPlugin;

public function getModuleName(): string
{
return 'Sale';
}

public function getId(): string
{
return 'sale';
}

public function boot(Panel $panel): void
{
// TODO: Implement boot() method.
}
}
32 changes: 32 additions & 0 deletions app/Providers/EventServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Modules\Sale\Providers;

use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;

class EventServiceProvider extends ServiceProvider
{
/**
* The event handler mappings for the application.
*
* @var array<string, array<int, string>>
*/
protected $listen = [];

/**
* Indicates if events should be discovered.
*
* @var bool
*/
protected static $shouldDiscoverEvents = true;

/**
* Configure the proper event listeners for email verification.
*
* @return void
*/
protected function configureEmailVerification(): void
{

}
}
49 changes: 49 additions & 0 deletions app/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace Modules\Sale\Providers;

use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Route;

class RouteServiceProvider extends ServiceProvider
{
/**
* Called before routes are registered.
*
* Register any model bindings or pattern based filters.
*/
public function boot(): void
{
parent::boot();
}

/**
* Define the routes for the application.
*/
public function map(): void
{
$this->mapApiRoutes();

$this->mapWebRoutes();
}

/**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*/
protected function mapWebRoutes(): void
{
Route::middleware('web')->group(module_path('Sale', '/routes/web.php'));
}

/**
* Define the "api" routes for the application.
*
* These routes are typically stateless.
*/
protected function mapApiRoutes(): void
{
Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Sale', '/routes/api.php'));
}
}
120 changes: 120 additions & 0 deletions app/Providers/SaleServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<?php

namespace Modules\Sale\Providers;

use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;

class SaleServiceProvider extends ServiceProvider
{
protected string $moduleName = 'Sale';

protected string $moduleNameLower = 'Sale';

/**
* Boot the application events.
*/
public function boot(): void
{
$this->registerCommands();
$this->registerCommandSchedules();
$this->registerTranslations();
$this->registerConfig();
$this->registerViews();
$this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations'));
}

/**
* 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->moduleNameLower);

if (is_dir($langPath)) {
$this->loadTranslationsFrom($langPath, $this->moduleNameLower);
$this->loadJsonTranslationsFrom($langPath);
} else {
$this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower);
$this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang'));
}
}

/**
* Register config.
*/
protected function registerConfig(): void
{
$this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower . '.php')], 'config');
$this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower);
}

/**
* Register views.
*/
public function registerViews(): void
{
$viewPath = resource_path('views/modules/' . $this->moduleNameLower);
$sourcePath = module_path($this->moduleName, 'resources/views');

$this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower . '-module-views']);

$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower);

$componentNamespace = str_replace('/', '\\', config('modules.namespace') . '\\' . $this->moduleName . '\\' . ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder', '')));
Blade::componentNamespace($componentNamespace, $this->moduleNameLower);
}

/**
* Get the services provided by the provider.
*
* @return array<string>
*/
public function provides(): array
{
return [];
}

/**
* @return array<string>
*/
private function getPublishableViewPaths(): array
{
$paths = [];
foreach (config('view.paths') as $path) {
if (is_dir($path . '/modules/' . $this->moduleNameLower)) {
$paths[] = $path . '/modules/' . $this->moduleNameLower;
}
}

return $paths;
}
}
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "mybizna/sale",
"description": "",
"type": "asgard-module",
"version": "2024.3",
"version": "2024.4",
"license": "GPL-3.0-or-later",
"authors": [
{
Expand Down Expand Up @@ -36,4 +36,4 @@
"Modules\\Sale\\Tests\\": "tests/"
}
}
}
}
Empty file added config/.gitkeep
Empty file.
5 changes: 5 additions & 0 deletions config/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

return [
'name' => 'Sale',
];
Empty file added routes/.gitkeep
Empty file.
12 changes: 12 additions & 0 deletions routes/api.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "api" middleware group. Now create something great!
|
*/
12 changes: 12 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

0 comments on commit 27af335

Please sign in to comment.