Add all files

This commit is contained in:
root
2025-11-30 11:57:22 +01:00
parent 2ee51cac4f
commit 044271db3d
1476 changed files with 142544 additions and 0 deletions

View File

@@ -0,0 +1,115 @@
<?php
namespace Paymenter\Extensions\Others\Pages\Admin\Resources;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Forms\Get;
use Filament\Forms\Set;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Support\Str;
use Paymenter\Extensions\Others\Pages\Admin\Resources\PageResource\Pages;
use Paymenter\Extensions\Others\Pages\Models\Page;
class PageResource extends Resource
{
protected static ?string $model = Page::class;
protected static ?string $navigationIcon = 'ri-file-text-line';
protected static ?string $navigationGroup = 'Configuration';
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('title')
->required()
->maxLength(255)
->live(onBlur: true)
->afterStateUpdated(function (Get $get, Set $set, ?string $old, ?string $state) {
if (($get('slug') ?? '') !== Str::slug($old)) {
return;
}
$set('slug', Str::slug($state));
}),
Forms\Components\TextInput::make('slug')->rule('regex:/^[a-z0-9-]+$/')
->required()->unique(ignoreRecord: true),
Forms\Components\Textarea::make('description'),
Forms\Components\RichEditor::make('content')->enableToolbarButtons()->hidden(fn (Get $get) => $get('as_html')),
Forms\Components\MarkdownEditor::make('content')->disableAllToolbarButtons()->hidden(fn (Get $get) => !$get('as_html')),
Forms\Components\Toggle::make('visible')
->label('Visible'),
Forms\Components\Toggle::make('as_html')
->live()
->label('Show content as raw HTML (also removes title from the page)'),
Forms\Components\Select::make('visibility')
->options([
'public' => __('Public'),
'client' => __('Customers Only'),
'admin' => __('Admin Only'),
])
->default('public'),
Forms\Components\Select::make('navigation')
->options([
'none' => __('None (hidden)'),
'top' => __('Top Navigation'),
'account_dropdown' => __('Account Dropdown (requires login)'),
'dashboard' => __('Client area/Dashboard (requires login)'),
])
->default('none')
->label('Show in navigation'),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('title')
->label('Title')
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('slug')
->label('Slug')
->searchable()
->sortable(),
Tables\Columns\IconColumn::make('visible')
->label('Visible')
->boolean(),
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
])
->reorderable('sort')
->defaultSort('sort', 'asc');
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListPages::route('/'),
'create' => Pages\CreatePage::route('/create'),
'edit' => Pages\EditPage::route('/{record}/edit'),
];
}
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Paymenter\Extensions\Others\Pages\Admin\Resources\PageResource\Pages;
use Filament\Resources\Pages\CreateRecord;
use Paymenter\Extensions\Others\Pages\Admin\Resources\PageResource;
class CreatePage extends CreateRecord
{
protected static string $resource = PageResource::class;
}

View File

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

View File

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

View File

@@ -0,0 +1,38 @@
<?php
namespace Paymenter\Extensions\Others\Pages\Livewire;
use App\Livewire\Component;
use Paymenter\Extensions\Others\Pages\Models\Page as ModelsPage;
class Page extends Component
{
public ModelsPage $page;
public function mount($fallbackPlaceholder)
{
// Validate if page exists
$this->page = ModelsPage::where('slug', $fallbackPlaceholder)->firstOrFail();
if (!$this->page->visible) {
abort(404);
}
// Validate if user is logged in
if ($this->page->visibility == 'client' && !auth()->check()) {
abort(404);
}
if ($this->page->visibility == 'admin' && (!auth()->check() || is_null(auth()->user()->role))) {
abort(404);
}
}
public function render()
{
return view('others.pages::page', [
'page' => $this->page,
])->layout('layouts.app', [
'title' => $this->page->title,
'description' => $this->page->description,
'sidebar' => $this->page->navigation == 'dashboard' ? true : false,
]);
}
}

View File

@@ -0,0 +1,33 @@
<?php
namespace Paymenter\Extensions\Others\Pages\Models;
use Illuminate\Database\Eloquent\Model;
class Page extends Model
{
protected $table = 'ext_pages';
protected $fillable = [
'slug',
'title',
'description',
'content',
'visible',
'as_html',
'visibility',
'navigation',
'sort',
];
protected $casts = [
'visible' => 'boolean',
'html' => 'boolean',
'visibility' => 'string',
];
public function getRouteKeyName()
{
return 'slug';
}
}

108
Disabled/Pages/Pages.php Normal file
View File

@@ -0,0 +1,108 @@
<?php
namespace Paymenter\Extensions\Others\Pages;
use App\Classes\Extension\Extension;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\View;
use Illuminate\Support\HtmlString;
use Paymenter\Extensions\Others\Pages\Admin\Resources\PageResource;
use Paymenter\Extensions\Others\Pages\Livewire\Page;
use Paymenter\Extensions\Others\Pages\Models\Page as ModelsPage;
class Pages extends Extension
{
/**
* Get all the configuration for the extension
*
* @param array $values
* @return array
*/
public function getConfig($values = [])
{
try {
return [
[
'name' => 'Notice',
'type' => 'placeholder',
'label' => new HtmlString('You can use this extension to create custom frontend pages, go to <a class="text-primary-600" href="' . PageResource::getUrl() . '">Pages</a> to get started.'),
],
];
} catch (\Exception $e) {
return [
[
'name' => 'Notice',
'type' => 'placeholder',
'label' => new HtmlString('You can use this extension to create custom frontend pages, you\'ll need to enable this extension above to get started.'),
],
];
}
}
public function enabled()
{
// Run migrations
Artisan::call('migrate', ['--path' => 'extensions/Others/Pages/database/migrations', '--force' => true]);
}
public function boot()
{
// Register routes
require __DIR__ . '/routes.php';
View::addNamespace('others.pages', __DIR__ . '/resources/views');
// Register livewire
\Livewire\Livewire::component('extensions.others.pages.show', Page::class);
Event::listen('navigation', function () {
if (ModelsPage::where('visible', true)->where('navigation', 'top')->count() == 0) {
return;
}
$pages = ModelsPage::where('visible', true)->where('navigation', 'top')->orderBy('sort')->get();
return $this->toNavigation($pages);
});
Event::listen('navigation.account-dropdown', function () {
if (ModelsPage::where('visible', true)->where('navigation', 'account_dropdown')->count() == 0) {
return;
}
$pages = ModelsPage::where('visible', true)->where('navigation', 'account_dropdown')->orderBy('sort')->get();
return $this->toNavigation($pages);
});
Event::listen('navigation.dashboard', function () {
if (ModelsPage::where('visible', true)->where('navigation', 'dashboard')->count() == 0) {
return;
}
$pages = ModelsPage::where('visible', true)->where('navigation', 'dashboard')->orderBy('sort')->get();
return $this->toNavigation($pages);
});
}
private function toNavigation($pages)
{
$navigation = [];
foreach ($pages as $page) {
if ($page->visibility == 'client' && !auth()->check()) {
continue;
}
if ($page->visibility == 'admin' && (!auth()->check() || is_null(auth()->user()->role))) {
continue;
}
$navigation[] = [
'name' => $page->title,
'route' => 'extensions.others.pages',
'params' => ['fallbackPlaceholder' => $page->slug],
];
}
return $navigation;
}
}

View File

@@ -0,0 +1,36 @@
<?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('ext_pages', function (Blueprint $table) {
$table->id();
$table->string('slug')->unique();
$table->string('title');
$table->text('description')->nullable();
$table->longText('content')->nullable();
$table->boolean('visible')->default(true);
$table->boolean('as_html')->default(false);
$table->enum('visibility', ['public', 'client', 'admin'])->default('public');
$table->enum('navigation', ['none', 'top', 'account_dropdown', 'dashboard'])->default('none');
$table->unsignedTinyInteger('sort')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('ext_pages');
}
};

8
Disabled/Pages/readme.md Normal file
View File

@@ -0,0 +1,8 @@
Thanks for buying this extension!
Buying this extension means you are supporting the development of Paymenter and helping us to keep it free for everyone.
To install this extension just drop it in the `extensions/Others` folder of your Paymenter installation. You can find the `extensions/Others` folder in the root directory of your Paymenter installation.
If you require assistance with this extension, please go to the [Paymenter Discord](https://discord.gg/kJWDZ86NUZ) and ask for help in the 3rd party support channel.

View File

@@ -0,0 +1,8 @@
<div class="prose dark:prose-invert max-w-full bg-background-secondary border border-neutral p-6 rounded-lg">
@if($page->as_html)
{!! $page->content !!}
@else
<h1 class="mb-2">{{ $page->title }}</h1>
<div>{!! $page->content !!}</div>
@endif
</div>

View File

@@ -0,0 +1,6 @@
<?php
use Illuminate\Support\Facades\Route;
use Paymenter\Extensions\Others\Pages\Livewire\Page;
Route::fallback(Page::class)->middleware('web')->name('extensions.others.pages');