generated from omnia-digital/catalyst-plugin-skeleton
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
9 changed files
with
277 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
19
database/migrations/create_catalyst_forms_plugin_table.php.stub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
|
||
// translations for OmniaDigital/CatalystFormsPlugin | ||
return [ | ||
// | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace OmniaDigital\CatalystFormsPlugin; | ||
|
||
class CatalystFormsPlugin | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
{ | ||
// | ||
} |