Skip to content

Commit

Permalink
- add initial config
Browse files Browse the repository at this point in the history
- add files from forms module
  • Loading branch information
joshtorres committed Oct 4, 2023
1 parent a7c9e8d commit caf5a6f
Show file tree
Hide file tree
Showing 9 changed files with 277 additions and 0 deletions.
6 changes: 6 additions & 0 deletions config/catalyst-forms-plugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

// config for OmniaDigital/CatalystFormsPlugin
return [

];
19 changes: 19 additions & 0 deletions database/migrations/create_catalyst_forms_plugin_table.php.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
public function up()
{
Schema::create('catalyst_forms_plugin_table', function (Blueprint $table) {
$table->id();

// add fields

$table->timestamps();
});
}
};
6 changes: 6 additions & 0 deletions resources/lang/en/catalyst-forms-plugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

// translations for OmniaDigital/CatalystFormsPlugin
return [
//
];
7 changes: 7 additions & 0 deletions src/CatalystFormsPlugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace OmniaDigital\CatalystFormsPlugin;

class CatalystFormsPlugin
{
}
37 changes: 37 additions & 0 deletions src/CatalystFormsPluginPlugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace OmniaDigital\CatalystFormsPlugin;

use Filament\Contracts\Plugin;
use Filament\Panel;

class CatalystFormsPluginPlugin implements Plugin
{
public function getId(): string
{
return 'catalyst-forms-plugin';
}

public function register(Panel $panel): void
{
//
}

public function boot(Panel $panel): void
{
//
}

public static function make(): static
{
return app(static::class);
}

public static function get(): static
{
/** @var static $plugin */
$plugin = filament(app(static::class)->getId());

return $plugin;
}
}
154 changes: 154 additions & 0 deletions src/CatalystFormsPluginServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
<?php

namespace OmniaDigital\CatalystFormsPlugin;

use Filament\Support\Assets\AlpineComponent;
use Filament\Support\Assets\Asset;
use Filament\Support\Assets\Css;
use Filament\Support\Assets\Js;
use Filament\Support\Facades\FilamentAsset;
use Filament\Support\Facades\FilamentIcon;
use Illuminate\Filesystem\Filesystem;
use Livewire\Features\SupportTesting\Testable;
use Spatie\LaravelPackageTools\Commands\InstallCommand;
use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;
use OmniaDigital\CatalystFormsPlugin\Commands\CatalystFormsPluginCommand;
use OmniaDigital\CatalystFormsPlugin\Testing\TestsCatalystFormsPlugin;

class CatalystFormsPluginServiceProvider extends PackageServiceProvider
{
public static string $name = 'catalyst-forms-plugin';

public static string $viewNamespace = 'catalyst-forms-plugin';

public function configurePackage(Package $package): void
{
/*
* This class is a Package Service Provider
*
* More info: https://github.com/spatie/laravel-package-tools
*/
$package->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<Asset>
*/
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<class-string>
*/
protected function getCommands(): array
{
return [
CatalystFormsPluginCommand::class,
];
}

/**
* @return array<string>
*/
protected function getIcons(): array
{
return [];
}

/**
* @return array<string>
*/
protected function getRoutes(): array
{
return [];
}

/**
* @return array<string, mixed>
*/
protected function getScriptData(): array
{
return [];
}

/**
* @return array<string>
*/
protected function getMigrations(): array
{
return [
'create_catalyst-forms-plugin_table',
];
}
}
19 changes: 19 additions & 0 deletions src/Commands/CatalystFormsPluginCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace OmniaDigital\CatalystFormsPlugin\Commands;

use Illuminate\Console\Command;

class CatalystFormsPluginCommand extends Command
{
public $signature = 'catalyst-forms-plugin';

public $description = 'My command';

public function handle(): int
{
$this->comment('All done');

return self::SUCCESS;
}
}
16 changes: 16 additions & 0 deletions src/Facades/CatalystFormsPlugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace OmniaDigital\CatalystFormsPlugin\Facades;

use Illuminate\Support\Facades\Facade;

/**
* @see \OmniaDigital\CatalystFormsPlugin\CatalystFormsPlugin
*/
class CatalystFormsPlugin extends Facade
{
protected static function getFacadeAccessor()
{
return \OmniaDigital\CatalystFormsPlugin\CatalystFormsPlugin::class;
}
}
13 changes: 13 additions & 0 deletions src/Testing/TestsCatalystFormsPlugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace OmniaDigital\CatalystFormsPlugin\Testing;

use Livewire\Features\SupportTesting\Testable;

/**
* @mixin Testable
*/
class TestsCatalystFormsPlugin
{
//
}

0 comments on commit caf5a6f

Please sign in to comment.