diff --git a/config/catalyst-forms-plugin.php b/config/catalyst-forms-plugin.php new file mode 100644 index 0000000..c1a8e7a --- /dev/null +++ b/config/catalyst-forms-plugin.php @@ -0,0 +1,6 @@ +id(); + + // add fields + + $table->timestamps(); + }); + } +}; diff --git a/resources/lang/en/catalyst-forms-plugin.php b/resources/lang/en/catalyst-forms-plugin.php new file mode 100644 index 0000000..f207df2 --- /dev/null +++ b/resources/lang/en/catalyst-forms-plugin.php @@ -0,0 +1,6 @@ +getId()); + + return $plugin; + } +} diff --git a/src/CatalystFormsPluginServiceProvider.php b/src/CatalystFormsPluginServiceProvider.php new file mode 100644 index 0000000..a27bd02 --- /dev/null +++ b/src/CatalystFormsPluginServiceProvider.php @@ -0,0 +1,154 @@ +name(static::$name) + ->hasCommands($this->getCommands()) + ->hasInstallCommand(function (InstallCommand $command) { + $command + ->publishConfigFile() + ->publishMigrations() + ->askToRunMigrations() + ->askToStarRepoOnGitHub('omnia-digital/catalyst-forms-plugin'); + }); + + $configFileName = $package->shortName(); + + if (file_exists($package->basePath("/../config/{$configFileName}.php"))) { + $package->hasConfigFile(); + } + + if (file_exists($package->basePath('/../database/migrations'))) { + $package->hasMigrations($this->getMigrations()); + } + + if (file_exists($package->basePath('/../resources/lang'))) { + $package->hasTranslations(); + } + + if (file_exists($package->basePath('/../resources/views'))) { + $package->hasViews(static::$viewNamespace); + } + } + + public function packageRegistered(): void + { + } + + public function packageBooted(): void + { + // Asset Registration + FilamentAsset::register( + $this->getAssets(), + $this->getAssetPackageName() + ); + + FilamentAsset::registerScriptData( + $this->getScriptData(), + $this->getAssetPackageName() + ); + + // Icon Registration + FilamentIcon::register($this->getIcons()); + + // Handle Stubs + if (app()->runningInConsole()) { + foreach (app(Filesystem::class)->files(__DIR__ . '/../stubs/') as $file) { + $this->publishes([ + $file->getRealPath() => base_path("stubs/catalyst-forms-plugin/{$file->getFilename()}"), + ], 'catalyst-forms-plugin-stubs'); + } + } + + // Testing + Testable::mixin(new TestsCatalystFormsPlugin()); + } + + protected function getAssetPackageName(): ?string + { + return 'omnia-digital/catalyst-forms-plugin'; + } + + /** + * @return array + */ + protected function getAssets(): array + { + return [ + // AlpineComponent::make('catalyst-forms-plugin', __DIR__ . '/../resources/dist/components/catalyst-forms-plugin.js'), + Css::make('catalyst-forms-plugin-styles', __DIR__ . '/../resources/dist/catalyst-forms-plugin.css'), + Js::make('catalyst-forms-plugin-scripts', __DIR__ . '/../resources/dist/catalyst-forms-plugin.js'), + ]; + } + + /** + * @return array + */ + protected function getCommands(): array + { + return [ + CatalystFormsPluginCommand::class, + ]; + } + + /** + * @return array + */ + protected function getIcons(): array + { + return []; + } + + /** + * @return array + */ + protected function getRoutes(): array + { + return []; + } + + /** + * @return array + */ + protected function getScriptData(): array + { + return []; + } + + /** + * @return array + */ + protected function getMigrations(): array + { + return [ + 'create_catalyst-forms-plugin_table', + ]; + } +} diff --git a/src/Commands/CatalystFormsPluginCommand.php b/src/Commands/CatalystFormsPluginCommand.php new file mode 100644 index 0000000..4e0c422 --- /dev/null +++ b/src/Commands/CatalystFormsPluginCommand.php @@ -0,0 +1,19 @@ +comment('All done'); + + return self::SUCCESS; + } +} diff --git a/src/Facades/CatalystFormsPlugin.php b/src/Facades/CatalystFormsPlugin.php new file mode 100644 index 0000000..ea427a4 --- /dev/null +++ b/src/Facades/CatalystFormsPlugin.php @@ -0,0 +1,16 @@ +