This commit is contained in:
Bozhidar Slaveykov 2024-04-03 00:01:32 +03:00
parent b3d9cc6d97
commit ca7a93f994
10 changed files with 253 additions and 2 deletions

View file

@ -0,0 +1,22 @@
<?php
namespace Modules\Microweber\App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Modules\Microweber\Database\factories\MicroweberInstallationFactory;
class MicroweberInstallation extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*/
protected $fillable = [];
protected static function newFactory(): MicroweberInstallationFactory
{
//return MicroweberInstallationFactory::new();
}
}

View file

@ -4,6 +4,7 @@ namespace Modules\Microweber\App\Providers;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
use Modules\Microweber\Providers\Filament\AdminPanelProvider;
class MicroweberServiceProvider extends ServiceProvider
{
@ -30,6 +31,7 @@ class MicroweberServiceProvider extends ServiceProvider
public function register(): void
{
$this->app->register(RouteServiceProvider::class);
$this->app->register(AdminPanelProvider::class);
}
/**

View file

@ -0,0 +1,48 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('microweber_installations', function (Blueprint $table) {
$table->id();
$table->bigInteger('website_id')->nullable();
$table->string('app_version')->nullable();
$table->string('installation_type')->nullable();
$table->string('db_version')->nullable();
$table->string('db_engine')->nullable();
$table->string('db_host')->nullable();
$table->string('db_port')->nullable();
$table->string('db_name')->nullable();
$table->string('db_user')->nullable();
$table->string('db_password')->nullable();
$table->string('db_prefix')->nullable();
$table->string('admin_email')->nullable();
$table->string('admin_password')->nullable();
$table->string('admin_username')->nullable();
$table->string('admin_first_name')->nullable();
$table->string('admin_last_name')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('microweber_installations');
}
};

View file

@ -0,0 +1,64 @@
<?php
namespace Modules\Microweber\Filament\Admin\Resources;
use Modules\Microweber\App\Models\MicroweberInstallation;
use Modules\Microweber\Filament\Admin\Resources\MicroweberInstallationResource\Pages;
use Modules\Microweber\Filament\Admin\Resources\MicroweberInstallationResource\RelationManagers;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
class MicroweberInstallationResource extends Resource
{
protected static ?string $model = MicroweberInstallation::class;
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
public static function form(Form $form): Form
{
return $form
->schema([
//
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
//
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListMicroweberInstallations::route('/'),
'create' => Pages\CreateMicroweberInstallation::route('/create'),
'edit' => Pages\EditMicroweberInstallation::route('/{record}/edit'),
];
}
}

View file

@ -0,0 +1,12 @@
<?php
namespace Modules\Microweber\Filament\Admin\Resources\MicroweberInstallationResource\Pages;
use Modules\Microweber\Filament\Admin\Resources\MicroweberInstallationResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;
class CreateMicroweberInstallation extends CreateRecord
{
protected static string $resource = MicroweberInstallationResource::class;
}

View file

@ -0,0 +1,19 @@
<?php
namespace Modules\Microweber\Filament\Admin\Resources\MicroweberInstallationResource\Pages;
use Modules\Microweber\Filament\Admin\Resources\MicroweberInstallationResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
class EditMicroweberInstallation extends EditRecord
{
protected static string $resource = MicroweberInstallationResource::class;
protected function getHeaderActions(): array
{
return [
Actions\DeleteAction::make(),
];
}
}

View file

@ -0,0 +1,19 @@
<?php
namespace Modules\Microweber\Filament\Admin\Resources\MicroweberInstallationResource\Pages;
use Modules\Microweber\Filament\Admin\Resources\MicroweberInstallationResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
class ListMicroweberInstallations extends ListRecords
{
protected static string $resource = MicroweberInstallationResource::class;
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
];
}
}

View file

@ -0,0 +1,63 @@
<?php
namespace Modules\Microweber\Providers\Filament;
use Filament\Http\Middleware\Authenticate;
use Filament\Http\Middleware\DisableBladeIconComponents;
use Filament\Http\Middleware\DispatchServingFilamentEvent;
use Filament\Pages;
use Filament\Panel;
use Filament\PanelProvider;
use Filament\Support\Colors\Color;
use Filament\Widgets;
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
use Illuminate\Cookie\Middleware\EncryptCookies;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
use Illuminate\Routing\Middleware\SubstituteBindings;
use Illuminate\Session\Middleware\AuthenticateSession;
use Illuminate\Session\Middleware\StartSession;
use Illuminate\View\Middleware\ShareErrorsFromSession;
class AdminPanelProvider extends PanelProvider
{
private string $module = "Microweber";
public function panel(Panel $panel): Panel
{
$moduleNamespace = $this->getModuleNamespace();
return $panel
->id('microweber::admin')
->path('admin/modules/microweber')
->colors([
'primary' => Color::Blue,
])
->discoverResources(in: module_path($this->module, 'Filament/Admin/Resources'), for: "$moduleNamespace\\Filament\\Admin\\Resources")
->discoverPages(in: module_path($this->module, 'Filament/Admin/Pages'), for: "$moduleNamespace\\Filament\\Admin\\Pages")
->pages([
Pages\Dashboard::class,
])
->discoverWidgets(in: module_path($this->module, 'Filament/Admin/Widgets'), for: "$moduleNamespace\\Filament\\Admin\\Widgets")
->widgets([
Widgets\AccountWidget::class,
Widgets\FilamentInfoWidget::class,
])
->middleware([
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
StartSession::class,
AuthenticateSession::class,
ShareErrorsFromSession::class,
VerifyCsrfToken::class,
SubstituteBindings::class,
DisableBladeIconComponents::class,
DispatchServingFilamentEvent::class,
])
->authMiddleware([
Authenticate::class,
]);
}
protected function getModuleNamespace(): string
{
return config('modules.namespace').'\\'.$this->module;
}
}

View file

@ -5,7 +5,8 @@
"keywords": [],
"priority": 0,
"providers": [
"Modules\\Microweber\\App\\Providers\\MicroweberServiceProvider"
"Modules\\Microweber\\App\\Providers\\MicroweberServiceProvider",
"Modules\\Microweber\\Providers\\Filament\\AdminPanelProvider"
],
"files": []
}

1
web/modules-git.txt Normal file
View file

@ -0,0 +1 @@
https://github.com/savannabits/filament-modules