Private
Public Access
1
0

Extension Install

This commit is contained in:
root
2025-12-03 14:23:33 +01:00
parent a06fdcb317
commit 2cea264127
29 changed files with 1795 additions and 0 deletions

View File

@@ -0,0 +1,93 @@
<?php
namespace Paymenter\Extensions\Others\NavbarManager\Database\Seeders;
use Illuminate\Database\Seeder;
use Paymenter\Extensions\Others\NavbarManager\Models\NavbarLink;
class NavbarLinkSeeder extends Seeder
{
public function run()
{
// Sample Primary Navbar Links
NavbarLink::create([
'name' => 'Help Center',
'type' => 'primary',
'link_type' => 'url',
'custom_url' => 'https://docs.example.com',
'icon' => 'ri-question-line',
'condition' => 'always_visible',
'sort_order' => 100,
'is_active' => true,
]);
NavbarLink::create([
'name' => 'Status Page',
'type' => 'primary',
'link_type' => 'url',
'custom_url' => 'https://status.example.com',
'icon' => 'ri-pulse-line',
'condition' => 'always_visible',
'sort_order' => 110,
'is_active' => true,
]);
// Sample Account Dropdown Link
NavbarLink::create([
'name' => 'Billing History',
'type' => 'account',
'link_type' => 'route',
'route_name' => 'invoices',
'icon' => 'ri-history-line',
'condition' => 'clients_only',
'sort_order' => 100,
'is_active' => true,
]);
// Sample Dashboard Link
NavbarLink::create([
'name' => 'Knowledge Base',
'type' => 'dashboard',
'link_type' => 'url',
'custom_url' => 'https://kb.example.com',
'icon' => 'ri-book-line',
'condition' => 'clients_only',
'sort_order' => 100,
'is_active' => true,
]);
// Sample with dropdown (parent-child)
$parent = NavbarLink::create([
'name' => 'Resources',
'type' => 'primary',
'link_type' => 'route',
'route_name' => 'home', // fallback
'icon' => 'ri-folder-line',
'condition' => 'always_visible',
'sort_order' => 90,
'is_active' => true,
]);
NavbarLink::create([
'name' => 'Downloads',
'type' => 'primary',
'link_type' => 'path',
'custom_path' => '/downloads',
'parent_id' => $parent->id,
'condition' => 'always_visible',
'sort_order' => 10,
'is_active' => true,
]);
NavbarLink::create([
'name' => 'Documentation',
'type' => 'primary',
'link_type' => 'url',
'custom_url' => 'https://docs.example.com',
'parent_id' => $parent->id,
'condition' => 'always_visible',
'sort_order' => 20,
'is_active' => true,
]);
}
}

View File

@@ -0,0 +1,42 @@
<?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('navbar_links', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->enum('type', ['primary', 'account', 'dashboard'])->default('primary');
$table->enum('link_type', ['route', 'path', 'url'])->default('route');
$table->string('route_name')->nullable();
$table->json('route_params')->nullable();
$table->string('custom_path')->nullable();
$table->string('custom_url')->nullable();
$table->string('icon')->nullable();
$table->enum('condition', [
'always_visible',
'always_hidden',
'clients_only',
'admin_only',
'guests_only'
])->default('always_visible');
$table->integer('sort_order')->default(0);
$table->boolean('is_active')->default(true);
$table->unsignedBigInteger('parent_id')->nullable();
$table->timestamps();
$table->foreign('parent_id')->references('id')->on('navbar_links')->onDelete('cascade');
$table->index(['type', 'is_active', 'sort_order']);
});
}
public function down()
{
Schema::dropIfExists('navbar_links');
}
};

View File

@@ -0,0 +1,24 @@
<?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::table('navbar_links', function (Blueprint $table) {
$table->boolean('is_default_override')->default(false)->after('link_type');
$table->string('default_route_key')->nullable()->after('is_default_override');
$table->integer('default_priority')->nullable()->after('default_route_key');
});
}
public function down()
{
Schema::table('navbar_links', function (Blueprint $table) {
$table->dropColumn(['is_default_override', 'default_route_key', 'default_priority']);
});
}
};

View File

@@ -0,0 +1,27 @@
<?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::table('navbar_links', function (Blueprint $table) {
$table->unsignedBigInteger('product_id')->nullable()->after('custom_url');
$table->unsignedBigInteger('category_id')->nullable()->after('product_id');
// Add foreign key constraints if needed
// $table->foreign('product_id')->references('id')->on('products')->onDelete('cascade');
// $table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade');
});
}
public function down()
{
Schema::table('navbar_links', function (Blueprint $table) {
$table->dropColumn(['product_id', 'category_id']);
});
}
};

View File

@@ -0,0 +1,19 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
public function up()
{
// For MySQL, we need to alter the enum column to include new values
DB::statement("ALTER TABLE navbar_links MODIFY COLUMN link_type ENUM('route', 'path', 'url', 'product', 'category') DEFAULT 'route'");
}
public function down()
{
// Revert back to original enum values
DB::statement("ALTER TABLE navbar_links MODIFY COLUMN link_type ENUM('route', 'path', 'url') DEFAULT 'route'");
}
};