From d6eba08f69971043768e6f6a82e442b8b0962148 Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Thu, 1 Aug 2024 09:21:55 +0700 Subject: [PATCH] wip --- .github/FUNDING.yml | 2 +- .github/ISSUE_TEMPLATE/config.yml | 6 +- .github/SECURITY.md | 2 +- .github/dependabot.yml | 12 - .github/workflows/dependabot-auto-merge.yml | 33 -- .github/workflows/phpstan.yml | 26 -- CHANGELOG.md | 2 +- LICENSE.md | 2 +- README.md | 32 +- bin/build.js | 2 +- composer.json | 40 +- config/menu-builder.php | 7 + config/skeleton.php | 6 - configure.php | 370 ------------------ database/factories/ModelFactory.php | 19 - .../migrations/create_menus_table.php.stub | 37 ++ .../migrations/create_skeleton_table.php.stub | 19 - package.json | 6 +- phpstan-baseline.neon | 0 phpstan.neon.dist | 14 - phpunit.xml.dist | 2 +- resources/dist/.gitkeep | 0 resources/dist/filament-menu-builder.css | 1 + resources/dist/filament-menu-builder.js | 25 ++ resources/js/index.js | 21 + resources/lang/en/menu-builder.php | 8 + resources/lang/en/skeleton.php | 6 - resources/views/.gitkeep | 0 .../views/components/menu-item.blade.php | 56 +++ resources/views/edit-record.blade.php | 67 ++++ .../livewire/create-custom-link.blade.php | 16 + resources/views/livewire/menu-items.blade.php | 23 ++ resources/views/livewire/panel.blade.php | 16 + src/Commands/SkeletonCommand.php | 19 - src/Facades/FilamentMenuBuilder.php | 18 + src/Facades/Skeleton.php | 16 - src/FilamentMenuBuilder.php | 7 + src/FilamentMenuBuilderPlugin.php | 89 +++++ src/FilamentMenuBuilderServiceProvider.php | 84 ++++ src/Livewire/CreateCustomLink.php | 70 ++++ src/Livewire/MenuItems.php | 127 ++++++ src/Livewire/MenuPanel.php | 76 ++++ src/MenuPanel/MenuPanel.php | 53 +++ src/MenuPanel/StaticMenu.php | 30 ++ src/Models/Menu.php | 28 ++ src/Models/MenuItem.php | 58 +++ src/Resources/MenuResource.php | 70 ++++ src/Resources/MenuResource/Pages/EditMenu.php | 33 ++ .../MenuResource/Pages/ListMenus.php | 21 + src/Skeleton.php | 5 - src/SkeletonPlugin.php | 37 -- src/SkeletonServiceProvider.php | 152 ------- src/SkeletonTheme.php | 39 -- src/Testing/TestsSkeleton.php | 13 - stubs/.gitkeep | 0 tailwind.config.js | 2 +- tests/ArchTest.php | 2 + tests/ExampleTest.php | 2 + tests/Pest.php | 4 +- tests/TestCase.php | 12 +- 60 files changed, 1096 insertions(+), 849 deletions(-) delete mode 100644 .github/dependabot.yml delete mode 100644 .github/workflows/dependabot-auto-merge.yml delete mode 100644 .github/workflows/phpstan.yml mode change 100644 => 100755 bin/build.js create mode 100644 config/menu-builder.php delete mode 100644 config/skeleton.php delete mode 100644 configure.php delete mode 100644 database/factories/ModelFactory.php create mode 100644 database/migrations/create_menus_table.php.stub delete mode 100644 database/migrations/create_skeleton_table.php.stub delete mode 100644 phpstan-baseline.neon delete mode 100644 phpstan.neon.dist delete mode 100644 resources/dist/.gitkeep create mode 100644 resources/dist/filament-menu-builder.css create mode 100644 resources/dist/filament-menu-builder.js create mode 100644 resources/lang/en/menu-builder.php delete mode 100644 resources/lang/en/skeleton.php delete mode 100644 resources/views/.gitkeep create mode 100644 resources/views/components/menu-item.blade.php create mode 100644 resources/views/edit-record.blade.php create mode 100644 resources/views/livewire/create-custom-link.blade.php create mode 100644 resources/views/livewire/menu-items.blade.php create mode 100644 resources/views/livewire/panel.blade.php delete mode 100644 src/Commands/SkeletonCommand.php create mode 100644 src/Facades/FilamentMenuBuilder.php delete mode 100644 src/Facades/Skeleton.php create mode 100644 src/FilamentMenuBuilder.php create mode 100644 src/FilamentMenuBuilderPlugin.php create mode 100644 src/FilamentMenuBuilderServiceProvider.php create mode 100644 src/Livewire/CreateCustomLink.php create mode 100644 src/Livewire/MenuItems.php create mode 100644 src/Livewire/MenuPanel.php create mode 100644 src/MenuPanel/MenuPanel.php create mode 100644 src/MenuPanel/StaticMenu.php create mode 100644 src/Models/Menu.php create mode 100644 src/Models/MenuItem.php create mode 100644 src/Resources/MenuResource.php create mode 100644 src/Resources/MenuResource/Pages/EditMenu.php create mode 100644 src/Resources/MenuResource/Pages/ListMenus.php delete mode 100644 src/Skeleton.php delete mode 100644 src/SkeletonPlugin.php delete mode 100644 src/SkeletonServiceProvider.php delete mode 100644 src/SkeletonTheme.php delete mode 100644 src/Testing/TestsSkeleton.php delete mode 100644 stubs/.gitkeep diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index c68765b..c411ff2 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1 +1 @@ -github: :vendor_name +github: datlechin diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 96701be..d213423 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,11 +1,11 @@ blank_issues_enabled: false contact_links: - name: Ask a question - url: https://github.com/:vendor_name/:package_name/discussions/new?category=q-a + url: https://github.com/datlechin/filament-menu-builder/discussions/new?category=q-a about: Ask the community for help - name: Request a feature - url: https://github.com/:vendor_name/:package_name/discussions/new?category=ideas + url: https://github.com/datlechin/filament-menu-builder/discussions/new?category=ideas about: Share ideas for new features - name: Report a security issue - url: https://github.com/:vendor_name/:package_name/security/policy + url: https://github.com/datlechin/filament-menu-builder/security/policy about: Learn how to notify us for sensitive bugs diff --git a/.github/SECURITY.md b/.github/SECURITY.md index 12ab7c2..2f1db74 100644 --- a/.github/SECURITY.md +++ b/.github/SECURITY.md @@ -1,3 +1,3 @@ # Security Policy -If you discover any security related issues, please email author@domain.com instead of using the issue tracker. +If you discover any security related issues, please email datlechin@gmail.com instead of using the issue tracker. diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 30c8a49..0000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,12 +0,0 @@ -# Please see the documentation for all configuration options: -# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates - -version: 2 -updates: - - - package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "weekly" - labels: - - "dependencies" \ No newline at end of file diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml deleted file mode 100644 index d266418..0000000 --- a/.github/workflows/dependabot-auto-merge.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: "Dependabot Auto-Merge" - -on: pull_request_target - -permissions: - pull-requests: write - contents: write - -jobs: - dependabot: - runs-on: ubuntu-latest - if: ${{ github.actor == 'dependabot[bot]' }} - steps: - - - name: Dependabot metadata - id: metadata - uses: dependabot/fetch-metadata@v1.6.0 - with: - github-token: "${{ secrets.GITHUB_TOKEN }}" - - - name: Auto-merge Dependabot PRs for semver-minor updates - if: ${{steps.metadata.outputs.update-type == 'version-update:semver-minor'}} - run: gh pr merge --auto --merge "$PR_URL" - env: - PR_URL: ${{github.event.pull_request.html_url}} - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} - - - name: Auto-merge Dependabot PRs for semver-patch updates - if: ${{steps.metadata.outputs.update-type == 'version-update:semver-patch'}} - run: gh pr merge --auto --merge "$PR_URL" - env: - PR_URL: ${{github.event.pull_request.html_url}} - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml deleted file mode 100644 index 3855a08..0000000 --- a/.github/workflows/phpstan.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: PHPStan - -on: - push: - paths: - - '**.php' - - 'phpstan.neon.dist' - -jobs: - phpstan: - name: phpstan - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.1' - coverage: none - - - name: Install composer dependencies - uses: ramsey/composer-install@v3 - - - name: Run PHPStan - run: ./vendor/bin/phpstan --error-format=github diff --git a/CHANGELOG.md b/CHANGELOG.md index 767365d..a8d7a11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -All notable changes to `:package_name` will be documented in this file. +All notable changes to `filament-menu-builder` will be documented in this file. ## 1.0.0 - 202X-XX-XX diff --git a/LICENSE.md b/LICENSE.md index 58c9ad4..42e802a 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) :vendor_name +Copyright (c) datlechin Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 98f321d..6eb6308 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,11 @@ -# :package_description +# Create and manage menus and menu items -[![Latest Version on Packagist](https://img.shields.io/packagist/v/:vendor_slug/:package_slug.svg?style=flat-square)](https://packagist.org/packages/:vendor_slug/:package_slug) -[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/:vendor_slug/:package_slug/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/:vendor_slug/:package_slug/actions?query=workflow%3Arun-tests+branch%3Amain) -[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/:vendor_slug/:package_slug/fix-php-code-styling.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/:vendor_slug/:package_slug/actions?query=workflow%3A"Fix+PHP+code+styling"+branch%3Amain) -[![Total Downloads](https://img.shields.io/packagist/dt/:vendor_slug/:package_slug.svg?style=flat-square)](https://packagist.org/packages/:vendor_slug/:package_slug) +[![Latest Version on Packagist](https://img.shields.io/packagist/v/datlechin/filament-menu-builder.svg?style=flat-square)](https://packagist.org/packages/datlechin/filament-menu-builder) +[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/datlechin/filament-menu-builder/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/datlechin/filament-menu-builder/actions?query=workflow%3Arun-tests+branch%3Amain) +[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/datlechin/filament-menu-builder/fix-php-code-styling.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/datlechin/filament-menu-builder/actions?query=workflow%3A"Fix+PHP+code+styling"+branch%3Amain) +[![Total Downloads](https://img.shields.io/packagist/dt/datlechin/filament-menu-builder.svg?style=flat-square)](https://packagist.org/packages/datlechin/filament-menu-builder) - ---- -This repo can be used to scaffold a Filament plugin. Follow these steps to get started: -1. Press the "Use this template" button at the top of this repo to create a new repo with the contents of this skeleton. -2. Run "php ./configure.php" to run a script that will replace all placeholders throughout all the files. -3. Make something great! ---- - This is where your description should go. Limit it to a paragraph or two. Consider adding a small example. @@ -22,26 +14,26 @@ This is where your description should go. Limit it to a paragraph or two. Consid You can install the package via composer: ```bash -composer require :vendor_slug/:package_slug +composer require datlechin/filament-menu-builder ``` You can publish and run the migrations with: ```bash -php artisan vendor:publish --tag=":package_slug-migrations" +php artisan vendor:publish --tag="filament-menu-builder-migrations" php artisan migrate ``` You can publish the config file with: ```bash -php artisan vendor:publish --tag=":package_slug-config" +php artisan vendor:publish --tag="filament-menu-builder-config" ``` Optionally, you can publish the views using ```bash -php artisan vendor:publish --tag=":package_slug-views" +php artisan vendor:publish --tag="filament-menu-builder-views" ``` This is the contents of the published config file: @@ -54,8 +46,8 @@ return [ ## Usage ```php -$variable = new VendorName\Skeleton(); -echo $variable->echoPhrase('Hello, VendorName!'); +$filamentMenuBuilder = new Datlechin\FilamentMenuBuilder(); +echo $filamentMenuBuilder->echoPhrase('Hello, Datlechin!'); ``` ## Testing @@ -78,7 +70,7 @@ Please review [our security policy](../../security/policy) on how to report secu ## Credits -- [:author_name](https://github.com/:author_username) +- [Ngo Quoc Dat](https://github.com/datlechin) - [All Contributors](../../contributors) ## License diff --git a/bin/build.js b/bin/build.js old mode 100644 new mode 100755 index 913baf4..94a3cbc --- a/bin/build.js +++ b/bin/build.js @@ -46,5 +46,5 @@ const defaultOptions = { compile({ ...defaultOptions, entryPoints: ['./resources/js/index.js'], - outfile: './resources/dist/skeleton.js', + outfile: './resources/dist/filament-menu-builder.js', }) diff --git a/composer.json b/composer.json index bb6be65..6185387 100644 --- a/composer.json +++ b/composer.json @@ -1,58 +1,50 @@ { - "name": ":vendor_slug/:package_slug", - "description": ":package_description", + "name": "datlechin/filament-menu-builder", + "description": "Create and manage menus and menu items", "keywords": [ - ":vendor_name", + "datlechin", "laravel", - ":package_slug" + "filament-menu-builder" ], - "homepage": "https://github.com/:vendor_slug/:package_slug", + "homepage": "https://github.com/datlechin/filament-menu-builder", "support": { - "issues": "https://github.com/:vendor_slug/:package_slug/issues", - "source": "https://github.com/:vendor_slug/:package_slug" + "issues": "https://github.com/datlechin/filament-menu-builder/issues", + "source": "https://github.com/datlechin/filament-menu-builder" }, "license": "MIT", "authors": [ { - "name": ":author_name", - "email": "author@domain.com", + "name": "Ngo Quoc Dat", + "email": "datlechin@gmail.com", "role": "Developer" } ], "require": { "php": "^8.1", "filament/filament": "^3.0", - "filament/forms": "^3.0", - "filament/tables": "^3.0", "spatie/laravel-package-tools": "^1.15.0" }, "require-dev": { "laravel/pint": "^1.0", "nunomaduro/collision": "^7.9", - "nunomaduro/larastan": "^2.0.1", "orchestra/testbench": "^8.0", "pestphp/pest": "^2.1", "pestphp/pest-plugin-arch": "^2.0", - "pestphp/pest-plugin-laravel": "^2.0", - "phpstan/extension-installer": "^1.1", - "phpstan/phpstan-deprecation-rules": "^1.0", - "phpstan/phpstan-phpunit": "^1.0", - "spatie/laravel-ray": "^1.26" + "pestphp/pest-plugin-laravel": "^2.0" }, "autoload": { "psr-4": { - "VendorName\\Skeleton\\": "src/", - "VendorName\\Skeleton\\Database\\Factories\\": "database/factories/" + "Datlechin\\FilamentMenuBuilder\\": "src/", + "Datlechin\\FilamentMenuBuilder\\Database\\Factories\\": "database/factories/" } }, "autoload-dev": { "psr-4": { - "VendorName\\Skeleton\\Tests\\": "tests/" + "Datlechin\\FilamentMenuBuilder\\Tests\\": "tests/" } }, "scripts": { "post-autoload-dump": "@php ./vendor/bin/testbench package:discover --ansi", - "analyse": "vendor/bin/phpstan analyse", "test": "vendor/bin/pest", "test-coverage": "vendor/bin/pest --coverage", "format": "vendor/bin/pint" @@ -67,13 +59,13 @@ "extra": { "laravel": { "providers": [ - "VendorName\\Skeleton\\SkeletonServiceProvider" + "Datlechin\\FilamentMenuBuilder\\FilamentMenuBuilderServiceProvider" ], "aliases": { - "Skeleton": "VendorName\\Skeleton\\Facades\\Skeleton" + "FilamentMenuBuilder": "Datlechin\\FilamentMenuBuilder\\Facades\\FilamentMenuBuilder" } } }, "minimum-stability": "dev", "prefer-stable": true -} +} \ No newline at end of file diff --git a/config/menu-builder.php b/config/menu-builder.php new file mode 100644 index 0000000..c50d7ac --- /dev/null +++ b/config/menu-builder.php @@ -0,0 +1,7 @@ +" : '') . "\e[0m"); -writeln("Namespace : \e[0;36m$vendorNamespace\\$className\e[0m"); -writeln("Class name : \e[0;36m$className\e[0m"); -writeln('---'); -writeln("\e[1;37mPackages & Utilities\e[0m"); -writeln('Larastan/PhpStan : ' . ($usePhpStan ? "\e[0;32mYes" : "\e[0;31mNo") . "\e[0m"); -writeln('Pint : ' . ($usePint ? "\e[0;32mYes" : "\e[0;31mNo") . "\e[0m"); -writeln('Use Dependabot : ' . ($useDependabot ? "\e[0;32mYes" : "\e[0;31mNo") . "\e[0m"); -writeln('Use Ray : ' . ($useLaravelRay ? "\e[0;32mYes" : "\e[0;31mNo") . "\e[0m"); -writeln('Auto-Changelog : ' . ($useUpdateChangelogWorkflow ? "\e[0;32mYes" : "\e[0;31mNo") . "\e[0m"); -if ($formsOnly) { - writeln("Filament/Forms : \e[0;32mYes\e[0m"); -} elseif ($tablesOnly) { - writeln("Filament/Tables : \e[0;32mYes\e[0m"); -} else { - writeln("Filament/Filament : \e[0;32mYes\e[0m"); -} -writeln('------'); -writeln("\r"); -writeln('This script will replace the above values in all relevant files in the project directory.'); -writeln("\r"); - -if (! confirm('Modify files?', true)) { - exit(1); -} - -if ($formsOnly) { - safeUnlink(__DIR__ . '/src/SkeletonTheme.php'); - safeUnlink(__DIR__ . '/src/SkeletonPlugin.php'); - - removeComposerDeps([ - 'filament/filament', - 'filament/tables', - ], 'require'); -} elseif ($tablesOnly) { - safeUnlink(__DIR__ . '/src/SkeletonTheme.php'); - safeUnlink(__DIR__ . '/src/SkeletonPlugin.php'); - - removeComposerDeps([ - 'filament/filament', - 'filament/forms', - ], 'require'); -} else { - if ($isTheme) { - safeUnlink(__DIR__ . '/src/SkeletonServiceProvider.php'); - safeUnlink(__DIR__ . '/src/SkeletonPlugin.php'); - safeUnlink(__DIR__ . '/src/Skeleton.php'); - removeDirectory(__DIR__ . '/bin'); - removeDirectory(__DIR__ . '/config'); - removeDirectory(__DIR__ . '/database'); - removeDirectory(__DIR__ . '/stubs'); - removeDirectory(__DIR__ . '/resources/js'); - removeDirectory(__DIR__ . '/resources/lang'); - removeDirectory(__DIR__ . '/resources/views'); - removeDirectory(__DIR__ . '/src/Commands'); - removeDirectory(__DIR__ . '/src/Facades'); - removeDirectory(__DIR__ . '/src/Testing'); - - setupPackageJsonForTheme(); - - } else { - safeUnlink(__DIR__ . '/src/SkeletonTheme.php'); - } - - removeComposerDeps([ - 'filament/forms', - 'filament/tables', - ], 'require'); -} - -$files = (str_starts_with(strtoupper(PHP_OS), 'WIN') ? replaceForWindows() : replaceForAllOtherOSes()); - -foreach ($files as $file) { - replaceInFile($file, [ - ':author_name' => $authorName, - ':author_username' => $authorUsername, - 'author@domain.com' => $authorEmail, - ':vendor_name' => $vendorName, - ':vendor_slug' => $vendorSlug, - 'VendorName' => $vendorNamespace, - ':package_name' => $packageName, - ':package_slug' => $packageSlug, - ':package_slug_without_prefix' => $packageSlugWithoutPrefix, - 'Skeleton' => $className, - 'skeleton' => $packageSlug, - 'migration_table_name' => titleSnake($packageSlug), - 'variable' => $variableName, - ':package_description' => $description, - ]); - - match (true) { - str_contains($file, determineSeparator('src/Skeleton.php')) => rename($file, determineSeparator('./src/' . $className . '.php')), - str_contains($file, determineSeparator('src/SkeletonServiceProvider.php')) => rename($file, determineSeparator('./src/' . $className . 'ServiceProvider.php')), - str_contains($file, determineSeparator('src/SkeletonTheme.php')) => rename($file, determineSeparator('./src/' . $className . (str_ends_with($className, 'Theme') ? '.php' : 'Theme.php'))), - str_contains($file, determineSeparator('src/SkeletonPlugin.php')) => rename($file, determineSeparator('./src/' . $className . 'Plugin.php')), - str_contains($file, determineSeparator('src/Facades/Skeleton.php')) => rename($file, determineSeparator('./src/Facades/' . $className . '.php')), - str_contains($file, determineSeparator('src/Commands/SkeletonCommand.php')) => rename($file, determineSeparator('./src/Commands/' . $className . 'Command.php')), - str_contains($file, determineSeparator('src/Testing/TestsSkeleton.php')) => rename($file, determineSeparator('./src/Testing/Tests' . $className . '.php')), - str_contains($file, determineSeparator('database/migrations/create_skeleton_table.php.stub')) => rename($file, determineSeparator('./database/migrations/create_' . titleSnake($packageSlugWithoutPrefix) . '_table.php.stub')), - str_contains($file, determineSeparator('config/skeleton.php')) => rename($file, determineSeparator('./config/' . $packageSlugWithoutPrefix . '.php')), - str_contains($file, determineSeparator('resources/lang/en/skeleton.php')) => rename($file, determineSeparator('./resources/lang/en/' . $packageSlugWithoutPrefix . '.php')), - str_contains($file, 'README.md') => removeTag($file, 'delete'), - default => [], - }; -} - -if (! $useDependabot) { - safeUnlink(__DIR__ . '/.github/dependabot.yml'); - safeUnlink(__DIR__ . '/.github/workflows/dependabot-auto-merge.yml'); -} - -if (! $useLaravelRay) { - removeComposerDeps(['spatie/laravel-ray'], 'require-dev'); -} - -if (! $usePhpStan) { - safeUnlink(__DIR__ . '/phpstan.neon.dist'); - safeUnlink(__DIR__ . '/phpstan-baseline.neon'); - safeUnlink(__DIR__ . '/.github/workflows/phpstan.yml'); - - removeComposerDeps([ - 'phpstan/extension-installer', - 'phpstan/phpstan-deprecation-rules', - 'phpstan/phpstan-phpunit', - 'nunomaduro/larastan', - ], 'require-dev'); - - removeComposerDeps(['analyse'], 'scripts'); -} - -if (! $usePint) { - safeUnlink(__DIR__ . '/.github/workflows/fix-php-code-style-issues.yml'); - safeUnlink(__DIR__ . '/pint.json'); - - removeComposerDeps([ - 'laravel/pint', - ], 'require-dev'); - - removeComposerDeps(['format'], 'scripts'); -} - -if (! $useUpdateChangelogWorkflow) { - safeUnlink(__DIR__ . '/.github/workflows/update-changelog.yml'); -} - -confirm('Execute `composer install`?') && run('composer install'); - -if (confirm('Let this script delete itself?', true)) { - unlink(__FILE__); -} - -function ask(string $question, string $default = ''): string -{ - $def = $default ? "\e[0;33m ($default)" : ''; - $answer = readline("\e[0;32m" . $question . $def . ": \e[0m"); - - if (! $answer) { - return $default; - } - - return $answer; -} - -function confirm(string $question, bool $default = false): bool -{ - $answer = ask($question, ($default ? 'Y/n' : 'y/N')); - - if (strtolower($answer) === 'y/n') { - return $default; - } - - return strtolower($answer) === 'y'; -} - -function writeln(string $line): void -{ - echo $line . PHP_EOL; -} - -function run(string $command): string -{ - return trim((string) shell_exec($command)); -} - -function slugify(string $subject): string -{ - return strtolower(trim(preg_replace('/[^A-Za-z0-9-]+/', '-', $subject), '-')); -} - -function titleCase(string $subject): string -{ - return str_replace(' ', '', ucwords(str_replace(['-', '_'], ' ', $subject))); -} - -function titleSnake(string $subject, string $replace = '_'): string -{ - return str_replace(['-', '_'], $replace, $subject); -} - -function replaceInFile(string $file, array $replacements): void -{ - $contents = file_get_contents($file); - - file_put_contents( - $file, - str_replace( - array_keys($replacements), - array_values($replacements), - $contents - ) - ); -} - -function removePrefix(string $prefix, string $content): string -{ - if (str_starts_with($content, $prefix)) { - return substr($content, strlen($prefix)); - } - - return $content; -} - -function removeComposerDeps(array $names, string $location): void -{ - $data = json_decode(file_get_contents(__DIR__ . '/composer.json'), true); - - foreach ($data[$location] as $name => $version) { - if (in_array($name, $names, true)) { - unset($data[$location][$name]); - } - } - - file_put_contents(__DIR__ . '/composer.json', json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); -} - -function removeNpmDeps(array $names, string $location): void -{ - $data = json_decode(file_get_contents(__DIR__ . '/package.json'), true); - - foreach ($data[$location] as $name => $version) { - if (in_array($name, $names, true)) { - unset($data[$location][$name]); - } - } - - file_put_contents(__DIR__ . '/package.json', json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | - JSON_UNESCAPED_UNICODE)); -} - -function removeTag(string $file, string $tag): void -{ - $contents = file_get_contents($file); - - file_put_contents( - $file, - preg_replace('/.*/s', '', $contents) ?: $contents - ); -} - -function setupPackageJsonForTheme(): void -{ - removeNpmDeps([ - 'purge', - 'dev', - 'dev:scripts', - 'build', - 'build:scripts', - ], 'scripts'); - - removeNpmDeps([ - '@awcodes/filament-plugin-purge', - 'esbuild', - 'npm-run-all', - 'prettier', - 'prettier-plugin-tailwindcss', - ], 'devDependencies'); - - replaceInFile(__DIR__ . '/package.json', [ - 'dev:styles' => 'dev', - 'build:styles' => 'build', - ]); -} - -function safeUnlink(string $filename): void -{ - if (file_exists($filename) && is_file($filename)) { - unlink($filename); - } -} - -function determineSeparator(string $path): string -{ - return str_replace('/', DIRECTORY_SEPARATOR, $path); -} - -function replaceForWindows(): array -{ - return preg_split('/\\r\\n|\\r|\\n/', run('dir /S /B * | findstr /v /i .git\ | findstr /v /i vendor | findstr /v /i ' . basename(__FILE__) . ' | findstr /r /i /M /F:/ ":author :vendor :package VendorName skeleton migration_table_name vendor_name vendor_slug author@domain.com"')); -} - -function replaceForAllOtherOSes(): array -{ - return explode(PHP_EOL, run('find ./* ./.github/* -name "vendor" -type d -prune \ - -o -name "configure.php" -prune \ - -o -type f -print0 | xargs -0 grep -E -r -l -i ":author|:vendor|:package|VendorName|skeleton|migration_table_name|vendor_name|vendor_slug|author@domain.com"')); -} - -function removeDirectory($dir): void -{ - if (is_dir($dir)) { - $objects = scandir($dir); - foreach ($objects as $object) { - if ($object != '.' && $object != '..') { - if (filetype($dir . '/' . $object) == 'dir') { - removeDirectory($dir . '/' . $object); - } else { - unlink($dir . '/' . $object); - } - } - } - rmdir($dir); - } -} diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.php deleted file mode 100644 index c51604f..0000000 --- a/database/factories/ModelFactory.php +++ /dev/null @@ -1,19 +0,0 @@ -id(); + $table->string('name'); + $table->string('location', 50); + $table->boolean('is_visible')->default(true); + $table->timestamps(); + }); + + Schema::create('menu_items', function (Blueprint $table) { + $table->id(); + $table->foreignIdFor(Menu::class); + $table->foreignIdFor(Menu::class, 'parent_id')->nullable(); + $table->nullableMorphs('linkable'); + $table->string('title'); + $table->string('url'); + $table->boolean('is_external')->default(false); + $table->integer('order')->default(0); + $table->timestamps(); + }); + } + + public function down(): void + { + Schema::dropIfExists('menu_items'); + Schema::dropIfExists('menus'); + } +}; diff --git a/database/migrations/create_skeleton_table.php.stub b/database/migrations/create_skeleton_table.php.stub deleted file mode 100644 index 2efdce9..0000000 --- a/database/migrations/create_skeleton_table.php.stub +++ /dev/null @@ -1,19 +0,0 @@ -id(); - - // add fields - - $table->timestamps(); - }); - } -}; diff --git a/package.json b/package.json index afec3c0..582ad86 100644 --- a/package.json +++ b/package.json @@ -2,11 +2,11 @@ "private": true, "type": "module", "scripts": { - "dev:styles": "npx tailwindcss -i resources/css/index.css -o resources/dist/skeleton.css --postcss --watch", + "dev:styles": "npx tailwindcss -i resources/css/index.css -o resources/dist/filament-menu-builder.css --postcss --watch", "dev:scripts": "node bin/build.js --dev", - "build:styles": "npx tailwindcss -i resources/css/index.css -o resources/dist/skeleton.css --postcss --minify && npm run purge", + "build:styles": "npx tailwindcss -i resources/css/index.css -o resources/dist/filament-menu-builder.css --postcss --minify && npm run purge", "build:scripts": "node bin/build.js", - "purge": "filament-purge -i resources/dist/skeleton.css -o resources/dist/skeleton.css -v 3.x", + "purge": "filament-purge -i resources/dist/filament-menu-builder.css -o resources/dist/filament-menu-builder.css -v 3.x", "dev": "npm-run-all --parallel dev:*", "build": "npm-run-all build:*" }, diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon deleted file mode 100644 index e69de29..0000000 diff --git a/phpstan.neon.dist b/phpstan.neon.dist deleted file mode 100644 index a91953b..0000000 --- a/phpstan.neon.dist +++ /dev/null @@ -1,14 +0,0 @@ -includes: - - phpstan-baseline.neon - -parameters: - level: 4 - paths: - - src - - config - - database - tmpDir: build/phpstan - checkOctaneCompatibility: true - checkModelProperties: true - checkMissingIterableValueType: false - diff --git a/phpunit.xml.dist b/phpunit.xml.dist index e953c0e..9652b97 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -16,7 +16,7 @@ backupStaticProperties="false" > - + tests diff --git a/resources/dist/.gitkeep b/resources/dist/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/resources/dist/filament-menu-builder.css b/resources/dist/filament-menu-builder.css new file mode 100644 index 0000000..6abb72e --- /dev/null +++ b/resources/dist/filament-menu-builder.css @@ -0,0 +1 @@ +/*! tailwindcss v3.4.7 | MIT License | https://tailwindcss.com*/*,:after,:before{box-sizing:border-box;border-width:0;border-style:solid;border-color:rgba(var(--gray-200),1)}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:var(--font-family),ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:initial}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:initial;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:initial}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:rgba(var(--gray-400),1)}input::placeholder,textarea::placeholder{opacity:1;color:rgba(var(--gray-400),1)}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}[multiple],[type=date],[type=datetime-local],[type=email],[type=month],[type=number],[type=password],[type=search],[type=tel],[type=text],[type=time],[type=url],[type=week],input:where(:not([type])),select,textarea{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:#fff;border-color:rgba(var(--gray-500),var(--tw-border-opacity,1));border-width:1px;border-radius:0;padding:.5rem .75rem;font-size:1rem;line-height:1.5rem;--tw-shadow:0 0 #0000}[multiple]:focus,[type=date]:focus,[type=datetime-local]:focus,[type=email]:focus,[type=month]:focus,[type=number]:focus,[type=password]:focus,[type=search]:focus,[type=tel]:focus,[type=text]:focus,[type=time]:focus,[type=url]:focus,[type=week]:focus,input:where(:not([type])):focus,select:focus,textarea:focus{outline:2px solid #0000;outline-offset:2px;--tw-ring-inset:var(--tw-empty,/*!*/ /*!*/);--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:#2563eb;--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow);border-color:#2563eb}input::-moz-placeholder,textarea::-moz-placeholder{color:rgba(var(--gray-500),var(--tw-text-opacity,1));opacity:1}input::placeholder,textarea::placeholder{color:rgba(var(--gray-500),var(--tw-text-opacity,1));opacity:1}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-date-and-time-value{min-height:1.5em;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit,::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-meridiem-field,::-webkit-datetime-edit-millisecond-field,::-webkit-datetime-edit-minute-field,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-second-field,::-webkit-datetime-edit-year-field{padding-top:0;padding-bottom:0}select{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='rgba(var(--gray-500), var(--tw-stroke-opacity, 1))' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3E%3C/svg%3E");background-position:right .5rem center;background-repeat:no-repeat;background-size:1.5em 1.5em;padding-right:2.5rem;-webkit-print-color-adjust:exact;print-color-adjust:exact}[multiple],[size]:where(select:not([size="1"])){background-image:none;background-position:0 0;background-repeat:unset;background-size:initial;padding-right:.75rem;-webkit-print-color-adjust:unset;print-color-adjust:unset}[type=checkbox],[type=radio]{-webkit-appearance:none;-moz-appearance:none;appearance:none;padding:0;-webkit-print-color-adjust:exact;print-color-adjust:exact;display:inline-block;vertical-align:middle;background-origin:border-box;-webkit-user-select:none;-moz-user-select:none;user-select:none;flex-shrink:0;height:1rem;width:1rem;color:#2563eb;background-color:#fff;border-color:rgba(var(--gray-500),var(--tw-border-opacity,1));border-width:1px;--tw-shadow:0 0 #0000}[type=checkbox]{border-radius:0}[type=radio]{border-radius:100%}[type=checkbox]:focus,[type=radio]:focus{outline:2px solid #0000;outline-offset:2px;--tw-ring-inset:var(--tw-empty,/*!*/ /*!*/);--tw-ring-offset-width:2px;--tw-ring-offset-color:#fff;--tw-ring-color:#2563eb;--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}[type=checkbox]:checked,[type=radio]:checked{border-color:#0000;background-color:currentColor;background-size:100% 100%;background-position:50%;background-repeat:no-repeat}[type=checkbox]:checked{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23fff' viewBox='0 0 16 16'%3E%3Cpath d='M12.207 4.793a1 1 0 0 1 0 1.414l-5 5a1 1 0 0 1-1.414 0l-2-2a1 1 0 0 1 1.414-1.414L6.5 9.086l4.293-4.293a1 1 0 0 1 1.414 0z'/%3E%3C/svg%3E")}@media (forced-colors:active){[type=checkbox]:checked{-webkit-appearance:auto;-moz-appearance:auto;appearance:auto}}[type=radio]:checked{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23fff' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='3'/%3E%3C/svg%3E")}@media (forced-colors:active){[type=radio]:checked{-webkit-appearance:auto;-moz-appearance:auto;appearance:auto}}[type=checkbox]:checked:focus,[type=checkbox]:checked:hover,[type=checkbox]:indeterminate,[type=radio]:checked:focus,[type=radio]:checked:hover{border-color:#0000;background-color:currentColor}[type=checkbox]:indeterminate{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 16 16'%3E%3Cpath stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 8h8'/%3E%3C/svg%3E");background-size:100% 100%;background-position:50%;background-repeat:no-repeat}@media (forced-colors:active){[type=checkbox]:indeterminate{-webkit-appearance:auto;-moz-appearance:auto;appearance:auto}}[type=checkbox]:indeterminate:focus,[type=checkbox]:indeterminate:hover{border-color:#0000;background-color:currentColor}[type=file]{background:unset;border-color:inherit;border-width:0;border-radius:0;padding:0;font-size:unset;line-height:inherit}[type=file]:focus{outline:1px solid ButtonText;outline:1px auto -webkit-focus-ring-color}:root.dark{color-scheme:dark}[data-field-wrapper]{scroll-margin-top:8rem}*,::backdrop,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:#3b82f680;--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }.col-span-12{grid-column:span 12/span 12}.ms-4{margin-inline-start:1rem}.rotate-180,.rotate-90{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-90{--tw-rotate:90deg}.scale-100,.scale-95{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.grid-cols-12{grid-template-columns:repeat(12,minmax(0,1fr))}.p-2\.5{padding:.625rem}.focus-visible\:ring-1:focus-visible,.focus-visible\:ring-2:focus-visible{box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.disabled\:placeholder\:\[-webkit-text-fill-color\:theme\(colors\.gray\.400\)\]:disabled::-moz-placeholder,.disabled\:placeholder\:\[-webkit-text-fill-color\:theme\(colors\.gray\.400\)\]:disabled::placeholder{-webkit-text-fill-color:rgba(var(--gray-400),1)}.group\/item:focus-visible .group-focus-visible\/item\:underline,.group\/link:focus-visible .group-focus-visible\/link\:underline{text-decoration-line:underline}.dark\:disabled\:placeholder\:\[-webkit-text-fill-color\:theme\(colors\.gray\.500\)\]:disabled:is(.dark *)::-moz-placeholder,.dark\:disabled\:placeholder\:\[-webkit-text-fill-color\:theme\(colors\.gray\.500\)\]:disabled:is(.dark *)::placeholder{-webkit-text-fill-color:rgba(var(--gray-500),1)}@media (min-width:640px){.sm\:col-span-4{grid-column:span 4/span 4}.sm\:col-span-8{grid-column:span 8/span 8}}:checked+*>.\[\:checked\+\*\>\&\]\:text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}input:checked+.\[input\:checked\+\&\]\:bg-custom-600{--tw-bg-opacity:1;background-color:rgba(var(--c-600),var(--tw-bg-opacity))}input:checked+.\[input\:checked\+\&\]\:bg-gray-400{--tw-bg-opacity:1;background-color:rgba(var(--gray-400),var(--tw-bg-opacity))}input:checked+.\[input\:checked\+\&\]\:text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}input:checked+.\[input\:checked\+\&\]\:ring-0{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}input:checked+.\[input\:checked\+\&\]\:hover\:bg-custom-500:hover{--tw-bg-opacity:1;background-color:rgba(var(--c-500),var(--tw-bg-opacity))}input:checked+.\[input\:checked\+\&\]\:hover\:bg-gray-300:hover{--tw-bg-opacity:1;background-color:rgba(var(--gray-300),var(--tw-bg-opacity))}input:checked+.dark\:\[input\:checked\+\&\]\:bg-custom-500:is(.dark *){--tw-bg-opacity:1;background-color:rgba(var(--c-500),var(--tw-bg-opacity))}input:checked+.dark\:\[input\:checked\+\&\]\:bg-gray-600:is(.dark *){--tw-bg-opacity:1;background-color:rgba(var(--gray-600),var(--tw-bg-opacity))}input:checked+.dark\:\[input\:checked\+\&\]\:hover\:bg-custom-400:hover:is(.dark *){--tw-bg-opacity:1;background-color:rgba(var(--c-400),var(--tw-bg-opacity))}input:checked+.dark\:\[input\:checked\+\&\]\:hover\:bg-gray-500:hover:is(.dark *){--tw-bg-opacity:1;background-color:rgba(var(--gray-500),var(--tw-bg-opacity))}input:checked:focus-visible+.\[input\:checked\:focus-visible\+\&\]\:ring-custom-500\/50{--tw-ring-color:rgba(var(--c-500),0.5)}input:checked:focus-visible+.dark\:\[input\:checked\:focus-visible\+\&\]\:ring-custom-400\/50:is(.dark *){--tw-ring-color:rgba(var(--c-400),0.5)}input:focus-visible+.\[input\:focus-visible\+\&\]\:z-10{z-index:10}input:focus-visible+.\[input\:focus-visible\+\&\]\:ring-2{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}input:focus-visible+.\[input\:focus-visible\+\&\]\:ring-gray-950\/10{--tw-ring-color:rgba(var(--gray-950),0.1)}input:focus-visible+.dark\:\[input\:focus-visible\+\&\]\:ring-white\/20:is(.dark *){--tw-ring-color:#fff3} \ No newline at end of file diff --git a/resources/dist/filament-menu-builder.js b/resources/dist/filament-menu-builder.js new file mode 100644 index 0000000..2297385 --- /dev/null +++ b/resources/dist/filament-menu-builder.js @@ -0,0 +1,25 @@ +// resources/js/index.js +var js_default = ({ parentId }) => ({ + parentId, + sortable: null, + init() { + this.sortable = new Sortable(this.$el, { + group: "nested", + draggable: "[data-sortable-item]", + handle: "[data-sortable-handle]", + animation: 300, + ghostClass: "fi-sortable-ghost", + dataIdAttr: "data-sortable-item", + onSort: () => { + this.$wire.reorder( + this.sortable.toArray(), + this.parentId === 0 ? null : this.parentId + ); + } + }); + } +}); +export { + js_default as default +}; +//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vanMvaW5kZXguanMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImV4cG9ydCBkZWZhdWx0ICh7IHBhcmVudElkIH0pID0+ICh7XG4gICAgcGFyZW50SWQsXG4gICAgc29ydGFibGU6IG51bGwsXG5cbiAgICBpbml0KCkge1xuICAgICAgICB0aGlzLnNvcnRhYmxlID0gbmV3IFNvcnRhYmxlKHRoaXMuJGVsLCB7XG4gICAgICAgICAgICBncm91cDogJ25lc3RlZCcsXG4gICAgICAgICAgICBkcmFnZ2FibGU6ICdbZGF0YS1zb3J0YWJsZS1pdGVtXScsXG4gICAgICAgICAgICBoYW5kbGU6ICdbZGF0YS1zb3J0YWJsZS1oYW5kbGVdJyxcbiAgICAgICAgICAgIGFuaW1hdGlvbjogMzAwLFxuICAgICAgICAgICAgZ2hvc3RDbGFzczogJ2ZpLXNvcnRhYmxlLWdob3N0JyxcbiAgICAgICAgICAgIGRhdGFJZEF0dHI6ICdkYXRhLXNvcnRhYmxlLWl0ZW0nLFxuICAgICAgICAgICAgb25Tb3J0OiAoKSA9PiB7XG4gICAgICAgICAgICAgICAgdGhpcy4kd2lyZS5yZW9yZGVyKFxuICAgICAgICAgICAgICAgICAgICB0aGlzLnNvcnRhYmxlLnRvQXJyYXkoKSxcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnRJZCA9PT0gMCA/IG51bGwgOiB0aGlzLnBhcmVudElkXG4gICAgICAgICAgICAgICAgKVxuICAgICAgICAgICAgfVxuICAgICAgICB9KVxuICAgIH0sXG59KVxuIl0sCiAgIm1hcHBpbmdzIjogIjtBQUFBLElBQU8sYUFBUSxDQUFDLEVBQUUsU0FBUyxPQUFPO0FBQUEsRUFDOUI7QUFBQSxFQUNBLFVBQVU7QUFBQSxFQUVWLE9BQU87QUFDSCxTQUFLLFdBQVcsSUFBSSxTQUFTLEtBQUssS0FBSztBQUFBLE1BQ25DLE9BQU87QUFBQSxNQUNQLFdBQVc7QUFBQSxNQUNYLFFBQVE7QUFBQSxNQUNSLFdBQVc7QUFBQSxNQUNYLFlBQVk7QUFBQSxNQUNaLFlBQVk7QUFBQSxNQUNaLFFBQVEsTUFBTTtBQUNWLGFBQUssTUFBTTtBQUFBLFVBQ1AsS0FBSyxTQUFTLFFBQVE7QUFBQSxVQUN0QixLQUFLLGFBQWEsSUFBSSxPQUFPLEtBQUs7QUFBQSxRQUN0QztBQUFBLE1BQ0o7QUFBQSxJQUNKLENBQUM7QUFBQSxFQUNMO0FBQ0o7IiwKICAibmFtZXMiOiBbXQp9Cg== diff --git a/resources/js/index.js b/resources/js/index.js index e69de29..10c74a7 100644 --- a/resources/js/index.js +++ b/resources/js/index.js @@ -0,0 +1,21 @@ +export default ({ parentId }) => ({ + parentId, + sortable: null, + + init() { + this.sortable = new Sortable(this.$el, { + group: 'nested', + draggable: '[data-sortable-item]', + handle: '[data-sortable-handle]', + animation: 300, + ghostClass: 'fi-sortable-ghost', + dataIdAttr: 'data-sortable-item', + onSort: () => { + this.$wire.reorder( + this.sortable.toArray(), + this.parentId === 0 ? null : this.parentId + ) + } + }) + }, +}) diff --git a/resources/lang/en/menu-builder.php b/resources/lang/en/menu-builder.php new file mode 100644 index 0000000..b0d1a00 --- /dev/null +++ b/resources/lang/en/menu-builder.php @@ -0,0 +1,8 @@ +children->isNotEmpty(); +@endphp + +
  • +
    +
    + {{ $this->reorderAction }} + + @if($hasChildren) + + @endif + +
    + {{ $item->title }} +
    +
    +
    + + {{ $item->type }} + + {{ ($this->editAction)(['id' => $item->getKey(), 'title' => $item->title]) }} + {{ ($this->deleteAction)(['id' => $item->getKey(), 'title' => $item->title]) }} +
    +
    + +
      + @foreach($item->children as $child) + + @endforeach +
    +
  • diff --git a/resources/views/edit-record.blade.php b/resources/views/edit-record.blade.php new file mode 100644 index 0000000..96c90d1 --- /dev/null +++ b/resources/views/edit-record.blade.php @@ -0,0 +1,67 @@ +getResource()::getSlug()), + 'fi-resource-record-' . $record->getKey(), + ]) +> + @capture($form) + + {{ $this->form }} + + + + @endcapture + + @php + $relationManagers = $this->getRelationManagers(); + $hasCombinedRelationManagerTabsWithContent = $this->hasCombinedRelationManagerTabsWithContent(); + @endphp + + @if ((! $hasCombinedRelationManagerTabsWithContent) || (! count($relationManagers))) + {{ $form() }} + @endif + + @if (count($relationManagers)) + + @if ($hasCombinedRelationManagerTabsWithContent) + + {{ $form() }} + + @endif + + @endif + +
    +
    + @foreach(\Datlechin\FilamentMenuBuilder\FilamentMenuBuilderPlugin::get()->getMenuPanels() as $menuPanel) + @livewire(\Datlechin\FilamentMenuBuilder\Livewire\MenuPanel::class, ['menu' => $record, 'menuPanel' => $menuPanel]) + @endforeach + + @livewire(\Datlechin\FilamentMenuBuilder\Livewire\CreateCustomLink::class, ['menu' => $record]) +
    +
    + + @livewire(\Datlechin\FilamentMenuBuilder\Livewire\MenuItems::class, ['menu' => $record]) + +
    +
    + + +
    diff --git a/resources/views/livewire/create-custom-link.blade.php b/resources/views/livewire/create-custom-link.blade.php new file mode 100644 index 0000000..f32c27f --- /dev/null +++ b/resources/views/livewire/create-custom-link.blade.php @@ -0,0 +1,16 @@ +
    + + {{ $this->form }} + + + + Thêm vào menu + + + +
    diff --git a/resources/views/livewire/menu-items.blade.php b/resources/views/livewire/menu-items.blade.php new file mode 100644 index 0000000..5c4e46d --- /dev/null +++ b/resources/views/livewire/menu-items.blade.php @@ -0,0 +1,23 @@ +
    + @if($this->menuItems->isNotEmpty()) +
      + @foreach($this->menuItems as $menuItem) + + @endforeach +
    + @else + + @endif + + +
    diff --git a/resources/views/livewire/panel.blade.php b/resources/views/livewire/panel.blade.php new file mode 100644 index 0000000..19a6eae --- /dev/null +++ b/resources/views/livewire/panel.blade.php @@ -0,0 +1,16 @@ +
    + + {{ $this->form }} + + + + Thêm vào menu + + + +
    diff --git a/src/Commands/SkeletonCommand.php b/src/Commands/SkeletonCommand.php deleted file mode 100644 index 3e5f628..0000000 --- a/src/Commands/SkeletonCommand.php +++ /dev/null @@ -1,19 +0,0 @@ -comment('All done'); - - return self::SUCCESS; - } -} diff --git a/src/Facades/FilamentMenuBuilder.php b/src/Facades/FilamentMenuBuilder.php new file mode 100644 index 0000000..3b7d327 --- /dev/null +++ b/src/Facades/FilamentMenuBuilder.php @@ -0,0 +1,18 @@ + + */ + protected array $menuPanels = []; + + public function getId(): string + { + return 'menu-builder'; + } + + public function register(Panel $panel): void + { + $panel->resources([ + MenuResource::class, + ]); + } + + 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; + } + + public function location(string $key, string $label): static + { + $this->locations[$key] = $label; + + return $this; + } + + public function menuPanel(Closure $callback): static + { + $panel = value($callback); + + if ($panel instanceof StaticMenu) { + if (! $panel->getItems()) { + return $this; + } + + $this->menuPanels[] = MenuPanel::make() + ->heading('Liên kết cố định') + ->addItems($panel->getItems()); + } else { + $this->menuPanels[] = $panel; + } + + return $this; + } + + /** + * @return MenuPanel[] + */ + public function getMenuPanels(): array + { + return $this->menuPanels; + } + + public function getLocations(): array + { + return $this->locations; + } +} diff --git a/src/FilamentMenuBuilderServiceProvider.php b/src/FilamentMenuBuilderServiceProvider.php new file mode 100644 index 0000000..29ded8f --- /dev/null +++ b/src/FilamentMenuBuilderServiceProvider.php @@ -0,0 +1,84 @@ +name(static::$name) + ->hasInstallCommand(function (InstallCommand $command) { + $command + ->publishConfigFile() + ->publishMigrations() + ->askToRunMigrations() + ->askToStarRepoOnGitHub('datlechin/filament-menu-builder'); + }); + + $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 + { + FilamentAsset::register( + $this->getAssets(), + $this->getAssetPackageName(), + ); + + Livewire::component('menu-builder-items', MenuItems::class); + Livewire::component('menu-builder-panel', MenuPanel::class); + } + + protected function getAssetPackageName(): ?string + { + return 'datlechin/filament-menu-builder'; + } + + protected function getAssets(): array + { + return [ + AlpineComponent::make('filament-menu-builder', __DIR__ . '/../resources/dist/filament-menu-builder.js'), + Css::make('filament-menu-builder-styles', __DIR__ . '/../resources/dist/filament-menu-builder.css'), + ]; + } + + protected function getMigrations(): array + { + return [ + 'create_menus_table', + ]; + } +} diff --git a/src/Livewire/CreateCustomLink.php b/src/Livewire/CreateCustomLink.php new file mode 100644 index 0000000..23658ba --- /dev/null +++ b/src/Livewire/CreateCustomLink.php @@ -0,0 +1,70 @@ +validate([ + 'data.title' => ['required', 'string'], + 'data.url' => ['required', 'string'], + 'data.is_external' => ['sometimes', 'bool'], + ]); + + $this->menu + ->menuItems() + ->create([ + ...$this->data, + 'order' => $this->menu->menuItems()->max('order') + 1, + ]); + + Notification::make() + ->title('Đã thêm liên kết tùy chỉnh vào menu.') + ->success() + ->send(); + + $this->reset(['data']); + $this->dispatch('menu:created'); + } + + public function form(Form $form): Form + { + return $form + ->statePath('data') + ->schema([ + TextInput::make('title') + ->label('Tiêu đề') + ->required(), + TextInput::make('url') + ->label('URL') + ->required(), + Checkbox::make('is_external') + ->default(false) + ->label('Liên kết bên ngoài'), + ]); + } + + public function render(): View + { + return view('filament-menu-builder::livewire.create-custom-link'); + } +} diff --git a/src/Livewire/MenuItems.php b/src/Livewire/MenuItems.php new file mode 100644 index 0000000..230d62c --- /dev/null +++ b/src/Livewire/MenuItems.php @@ -0,0 +1,127 @@ +menu->menuItems()->get(); + } + + public function reorder(array $order, ?string $parentId = null): void + { + if (empty($order)) { + return; + } + + MenuItem::query() + ->whereIn('id', $order) + ->update([ + 'order' => DB::raw( + 'case ' . collect($order) + ->map(fn($recordKey, int $recordIndex): string => 'when id = ' . DB::getPdo()->quote($recordKey) . ' then ' . ($recordIndex + 1)) + ->implode(' ') . ' end', + ), + 'parent_id' => $parentId, + ]); + } + + public function reorderAction(): Action + { + return Action::make('reorder') + ->label(__('filament-forms::components.builder.actions.reorder.label')) + ->icon(FilamentIcon::resolve('forms::components.builder.actions.reorder') ?? 'heroicon-m-arrows-up-down') + ->color('gray') + ->iconButton() + ->extraAttributes(['data-sortable-handle' => true, 'class' => 'cursor-move']) + ->livewireClickHandlerEnabled(false) + ->size(ActionSize::Small); + } + + public function editAction(): Action + { + return Action::make('edit') + ->label(__('filament-actions::edit.single.label')) + ->iconButton() + ->size(ActionSize::Small) + ->modalHeading(fn(array $arguments): string => __('filament-actions::edit.single.modal.heading', ['label' => $arguments['title']])) + ->icon('heroicon-m-pencil-square') + ->fillForm(fn(array $arguments): array => MenuItem::query() + ->where('id', $arguments['id']) + ->select(['id', 'title', 'url', 'is_external']) + ->first() + ->toArray()) + ->form([ + TextInput::make('title') + ->label('Tiêu đề') + ->required(), + TextInput::make('url') + ->label('URL') + ->required(), + Checkbox::make('is_external') + ->label('Liên kết bên ngoài') + ->default(false), + ]) + ->action(function (array $data, array $arguments) { + MenuItem::query() + ->where('id', $arguments['id']) + ->update($data); + }) + ->modalWidth(MaxWidth::Medium) + ->slideOver(); + } + + public function deleteAction(): Action + { + return Action::make('delete') + ->label(__('filament-actions::delete.single.label')) + ->color('danger') + ->groupedIcon(FilamentIcon::resolve('actions::delete-action.grouped') ?? 'heroicon-m-trash') + ->icon('heroicon-s-trash') + ->iconButton() + ->size(ActionSize::Small) + ->requiresConfirmation() + ->modalHeading(fn(array $arguments): string => __('filament-actions::delete.single.modal.heading', ['label' => $arguments['title']])) + ->modalSubmitActionLabel(__('filament-actions::delete.single.modal.actions.delete.label')) + ->modalIcon(FilamentIcon::resolve('actions::delete-action.modal') ?? 'heroicon-o-trash') + ->action(function (array $arguments): void { + $menuItem = MenuItem::query()->where('id', $arguments['id'])->first(); + + $menuItem?->delete(); + }); + } + + public function render(): View + { + return view('filament-menu-builder::livewire.menu-items'); + } +} diff --git a/src/Livewire/MenuPanel.php b/src/Livewire/MenuPanel.php new file mode 100644 index 0000000..306c854 --- /dev/null +++ b/src/Livewire/MenuPanel.php @@ -0,0 +1,76 @@ +heading = $menuPanel->getHeading(); + $this->items = $menuPanel->getItems(); + } + + public function add(): void + { + $this->validate(); + + $order = $this->menu->menuItems()->max('order') ?? 0; + + $selectedItems = collect($this->items) + ->filter(fn($item) => in_array($item['title'], $this->data)) + ->map(function ($item) use (&$order) { + return [ + ...$item, + 'order' => ++$order, + ]; + }); + + if ($selectedItems->isEmpty()) { + return; + } + + $this->menu->menuItems()->createMany($selectedItems); + + $this->reset('data'); + $this->dispatch('menu:created'); + } + + public function form(Form $form): Form + { + return $form + ->schema([ + CheckboxList::make('data') + ->hiddenLabel() + ->required() + ->bulkToggleable() + ->options(collect($this->items)->mapWithKeys(fn($item) => [$item['title'] => $item['title']])), + ]); + } + + public function render(): View + { + return view('filament-menu-builder::livewire.panel'); + } +} diff --git a/src/MenuPanel/MenuPanel.php b/src/MenuPanel/MenuPanel.php new file mode 100644 index 0000000..29606a2 --- /dev/null +++ b/src/MenuPanel/MenuPanel.php @@ -0,0 +1,53 @@ +heading = $heading; + + return $this; + } + + public function addItem(string $title, \Closure|string $url): static + { + $this->items[] = [ + 'title' => $title, + 'url' => $url, + ]; + + return $this; + } + + public function addItems(array $items): static + { + foreach ($items as $item) { + $this->addItem($item['title'], $item['url']); + } + + return $this; + } + + public function getHeading(): string + { + return $this->heading; + } + + public function getItems(): array + { + return $this->items; + } +} diff --git a/src/MenuPanel/StaticMenu.php b/src/MenuPanel/StaticMenu.php new file mode 100644 index 0000000..9a9f791 --- /dev/null +++ b/src/MenuPanel/StaticMenu.php @@ -0,0 +1,30 @@ +items[] = [ + 'title' => $title, + 'url' => $url, + ]; + + return $this; + } + + public function getItems(): array + { + return $this->items; + } +} diff --git a/src/Models/Menu.php b/src/Models/Menu.php new file mode 100644 index 0000000..a727210 --- /dev/null +++ b/src/Models/Menu.php @@ -0,0 +1,28 @@ + 'bool', + ]; + } + + public function menuItems(): HasMany + { + return $this->hasMany(MenuItem::class) + ->whereNull('parent_id') + ->with('children') + ->orderBy('order'); + } +} diff --git a/src/Models/MenuItem.php b/src/Models/MenuItem.php new file mode 100644 index 0000000..9f7c27e --- /dev/null +++ b/src/Models/MenuItem.php @@ -0,0 +1,58 @@ + 'int', + 'is_external' => 'bool', + ]; + } + + protected static function booted(): void + { + static::deleted(function (self $menuItem) { + $menuItem->children->each->delete(); + }); + } + + public function menu(): BelongsTo + { + return $this->belongsTo(Menu::class); + } + + public function parent(): BelongsTo + { + return $this->belongsTo(static::class); + } + + public function children(): HasMany + { + return $this->hasMany(static::class, 'parent_id') + ->with('children') + ->orderBy('order'); + } + + public function linkable(): MorphTo + { + return $this->morphTo(); + } + + protected function type(): Attribute + { + return Attribute::get(fn() => $this->linkable ? $this->linkable->title : 'Liên kết tùy chỉnh'); + } +} diff --git a/src/Resources/MenuResource.php b/src/Resources/MenuResource.php new file mode 100644 index 0000000..258eee7 --- /dev/null +++ b/src/Resources/MenuResource.php @@ -0,0 +1,70 @@ +columns(1) + ->schema([ + TextInput::make('name') + ->label('Tên') + ->required(), + Radio::make('location') + ->visible(fn() => FilamentMenuBuilderPlugin::get()->getLocations()) + ->label('Vị trí') + ->helperText('Chọn vị trí hiển thị menu.') + ->options(FilamentMenuBuilderPlugin::get()->getLocations()), + Checkbox::make('is_visible') + ->label('Hiển thị') + ->default(true), + ]); + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + Tables\Columns\TextColumn::make('name') + ->searchable() + ->label('Tên'), + Tables\Columns\IconColumn::make('is_visible') + ->label('Hiển thị') + ->boolean(), + ]) + ->actions([ + Tables\Actions\EditAction::make(), + ]) + ->bulkActions([ + Tables\Actions\BulkActionGroup::make([ + Tables\Actions\DeleteBulkAction::make(), + ]), + ]); + } + + public static function getPages(): array + { + return [ + 'index' => \Datlechin\FilamentMenuBuilder\Resources\MenuResource\Pages\ListMenus::route('/'), + 'edit' => \Datlechin\FilamentMenuBuilder\Resources\MenuResource\Pages\EditMenu::route('/{record}/edit'), + ]; + } +} diff --git a/src/Resources/MenuResource/Pages/EditMenu.php b/src/Resources/MenuResource/Pages/EditMenu.php new file mode 100644 index 0000000..05666a2 --- /dev/null +++ b/src/Resources/MenuResource/Pages/EditMenu.php @@ -0,0 +1,33 @@ +schema([ + Section::make()->schema($form->getComponents()), + ]); + } + + protected function getHeaderActions(): array + { + return [ + Actions\DeleteAction::make(), + ]; + } +} diff --git a/src/Resources/MenuResource/Pages/ListMenus.php b/src/Resources/MenuResource/Pages/ListMenus.php new file mode 100644 index 0000000..7cd41e7 --- /dev/null +++ b/src/Resources/MenuResource/Pages/ListMenus.php @@ -0,0 +1,21 @@ +getId()); - - return $plugin; - } -} diff --git a/src/SkeletonServiceProvider.php b/src/SkeletonServiceProvider.php deleted file mode 100644 index 6caab3f..0000000 --- a/src/SkeletonServiceProvider.php +++ /dev/null @@ -1,152 +0,0 @@ -name(static::$name) - ->hasCommands($this->getCommands()) - ->hasInstallCommand(function (InstallCommand $command) { - $command - ->publishConfigFile() - ->publishMigrations() - ->askToRunMigrations() - ->askToStarRepoOnGitHub(':vendor_slug/:package_slug'); - }); - - $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/skeleton/{$file->getFilename()}"), - ], 'skeleton-stubs'); - } - } - - // Testing - Testable::mixin(new TestsSkeleton); - } - - protected function getAssetPackageName(): ?string - { - return ':vendor_slug/:package_slug'; - } - - /** - * @return array - */ - protected function getAssets(): array - { - return [ - // AlpineComponent::make('skeleton', __DIR__ . '/../resources/dist/components/skeleton.js'), - Css::make('skeleton-styles', __DIR__ . '/../resources/dist/skeleton.css'), - Js::make('skeleton-scripts', __DIR__ . '/../resources/dist/skeleton.js'), - ]; - } - - /** - * @return array - */ - protected function getCommands(): array - { - return [ - SkeletonCommand::class, - ]; - } - - /** - * @return array - */ - protected function getIcons(): array - { - return []; - } - - /** - * @return array - */ - protected function getRoutes(): array - { - return []; - } - - /** - * @return array - */ - protected function getScriptData(): array - { - return []; - } - - /** - * @return array - */ - protected function getMigrations(): array - { - return [ - 'create_skeleton_table', - ]; - } -} diff --git a/src/SkeletonTheme.php b/src/SkeletonTheme.php deleted file mode 100644 index 6c647e0..0000000 --- a/src/SkeletonTheme.php +++ /dev/null @@ -1,39 +0,0 @@ -font('DM Sans') - ->primaryColor(Color::Amber) - ->secondaryColor(Color::Gray) - ->warningColor(Color::Amber) - ->dangerColor(Color::Rose) - ->successColor(Color::Green) - ->grayColor(Color::Gray) - ->theme('skeleton'); - } - - public function boot(Panel $panel): void - { - // - } -} diff --git a/src/Testing/TestsSkeleton.php b/src/Testing/TestsSkeleton.php deleted file mode 100644 index 0e33b51..0000000 --- a/src/Testing/TestsSkeleton.php +++ /dev/null @@ -1,13 +0,0 @@ -expect(['dd', 'dump', 'ray']) ->each->not->toBeUsed(); diff --git a/tests/ExampleTest.php b/tests/ExampleTest.php index 5d36321..57349d9 100644 --- a/tests/ExampleTest.php +++ b/tests/ExampleTest.php @@ -1,5 +1,7 @@ toBeTrue(); }); diff --git a/tests/Pest.php b/tests/Pest.php index 7fe1500..700bd46 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -1,5 +1,7 @@ in(__DIR__); diff --git a/tests/TestCase.php b/tests/TestCase.php index 14a77a0..edbd1a2 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -1,6 +1,8 @@ 'VendorName\\Skeleton\\Database\\Factories\\' . class_basename($modelName) . 'Factory' + fn(string $modelName) => 'Datlechin\\FilamentMenuBuilder\\Database\\Factories\\' . class_basename($modelName) . 'Factory', ); } @@ -44,7 +46,7 @@ protected function getPackageProviders($app) SupportServiceProvider::class, TablesServiceProvider::class, WidgetsServiceProvider::class, - SkeletonServiceProvider::class, + FilamentMenuBuilderServiceProvider::class, ]; } @@ -53,7 +55,7 @@ public function getEnvironmentSetUp($app) config()->set('database.default', 'testing'); /* - $migration = include __DIR__.'/../database/migrations/create_skeleton_table.php.stub'; + $migration = include __DIR__.'/../database/migrations/create_filament-menu-builder_table.php.stub'; $migration->up(); */ }