Skip to content

Commit

Permalink
install both packages
Browse files Browse the repository at this point in the history
  • Loading branch information
Kim-the-Diamond committed Jul 23, 2024
1 parent 64aa9dc commit fb4de90
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 5 deletions.
9 changes: 9 additions & 0 deletions app/Providers/Filament/PressPanelProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ public function panel(Panel $panel): Panel
\Moox\Press\WpUserPlugin::make(),
\Moox\Press\WpOptionPlugin::make(),


\Moox\Expiry\ExpiryPlugin::make(),


\Moox\Training\TrainingPlugin::make(),
\Moox\Training\TrainingInvitationPlugin::make(),
\Moox\Training\TrainingDatePlugin::make(),
\Moox\Training\TrainingTypePlugin::make(),

]);
}
}
25 changes: 25 additions & 0 deletions config/expiry.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

return [
'navigation_sort' => 2001,
'navigation_label' => 'Moox Expiry',

'user_model' => \Moox\Press\Models\WpUser::class,
'default_notified_to' => 1,

// Disable manual action buttons in UI
'create_expiry_action' => false,
'collect_expiries_action' => true,
'send_summary_action' => true,

// Jobs for expiries, create custom jobs if needed
// use and customize CollectExpiries instead of DemoExpiries
// DemoExpiries is just a job for creating demo data:
// 'collect_expiries_job' => \Moox\Expiry\Jobs\CollectExpiries::class,
'collect_expiries_jobs' => [
\Moox\Expiry\Jobs\CollectExpiries::class,
// Add more jobs here if needed.
],
'send_summary_job' => \Moox\Expiry\Jobs\SendSummary::class,
'api' => true,
];
16 changes: 16 additions & 0 deletions config/trainings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

return [
'navigation_sort' => 2001,

// Wire with one or more user models
'user_models' => [
'App Users' => \App\Models\User::class,
],

// Disable manual action buttons in UI
// and queue the provided jobs instead
'create_trainings_action' => true,
'training_invitations_collect_action' => true,
'training_invitations_send_action' => true,
];
43 changes: 43 additions & 0 deletions database/migrations/2024_07_23_150221_create_expiries_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

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

return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('expiries', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('title');
$table->string('slug');
$table->unsignedBigInteger('item_id');
$table->unsignedBigInteger('meta_id')->nullable();
$table->string('link');
$table->string('expiry_job');
$table->string('category')->nullable();
$table->string('status')->nullable();
$table->dateTime('expired_at');
$table->dateTime('notified_at')->nullable();
$table->unsignedBigInteger('notified_to')->nullable();
$table->dateTime('escalated_at')->nullable();
$table->unsignedBigInteger('escalated_to')->nullable();
$table->unsignedBigInteger('handled_by')->nullable();
$table->dateTime('done_at')->nullable();

$table->timestamps();
$table->softDeletes();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('expiries');
}
};
40 changes: 35 additions & 5 deletions packages/expiry/src/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,15 @@ public function handle()
$this->publishConfiguration();
$this->publishMigrations();
$this->runMigrations();
$this->registerPlugins();
$providerPath = app_path('Providers\Filament');
$panelsToregister = $this->getPanelProviderPath();
if (count($panelsToregister) > 0 && $panelsToregister != null) {
foreach ($panelsToregister as $panelprovider) {
$this->registerPlugins($providerPath.'/'.$panelprovider);
}
} else {
$this->registerPlugins($panelsToregister[0]);
}
$this->finish();
}

Expand Down Expand Up @@ -103,10 +111,8 @@ public function runMigrations(): void
}
}

public function registerPlugins(): void
public function registerPlugins(string $providerPath): void
{
$providerPath = app_path('Providers/Filament/AdminPanelProvider.php');

if (File::exists($providerPath)) {
$content = File::get($providerPath);

Expand Down Expand Up @@ -152,8 +158,32 @@ public function registerPlugins(): void
File::put($providerPath, $newContent);
}
} else {
alert('AdminPanelProvider not found. You need to add the plugins manually.');
alert($providerPath.' not found. You need to add the plugins manually.');
}
}

public function getPanelProviderPath(): string|array
{
$providerPath = app_path('Providers\Filament');
$providers = File::allFiles($providerPath);
if (count($providers) > 1) {
$providerNames = [];
foreach ($providers as $provider) {
$providerNames[] = $provider->getBasename();
}
$providerPath = multiselect(
label: 'Which Panel should it be registered',
options: [...$providerNames],
default: [$providerNames[0]],
);

}
if (count($providers) == 1) {
$providerPath .= '/'.$providers[0]->getBasename();
}

return $providerPath;

}

public function finish(): void
Expand Down

0 comments on commit fb4de90

Please sign in to comment.