Skip to content

Commit

Permalink
first commit 🔥
Browse files Browse the repository at this point in the history
  • Loading branch information
3x1io committed Apr 14, 2024
1 parent 705d3b2 commit 3d39c2c
Show file tree
Hide file tree
Showing 67 changed files with 2,625 additions and 193 deletions.
61 changes: 61 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@

Manage your modules as a plugin system with plugin generator

## Screenshots

![Plugins](./arts/plugins.png)
![Tables](./arts/tables.png)
![Generate](./arts/generate.png)
![Create Col](./arts/create-col.png)
![Table cols](./arts/table-cols.png)

## Installation

```bash
Expand All @@ -15,6 +23,59 @@ after install your package please run this command
php artisan filament-plugins:install
```

By default the module classes are not loaded automatically. You can autoload your modules by adding merge-plugin to the extra section:

```json
"extra": {
"laravel": {
"dont-discover": []
},
"merge-plugin": {
"include": [
"Modules/*/composer.json"
]
}
},
```

now you need to run this command to autoload your modules

```bash
composer dump-autoload
```

finally reigster the plugin on `/app/Providers/Filament/AdminPanelProvider.php`

```php
->plugin(\TomatoPHP\FilamentPlugins\FilamentPluginsPlugin::make())
```

## Usage

you can create a new plugin using just a command

```bash
php artisan filament-plugins:generate
```

or you can use the GUI to create a new plugin, after create a plugin you need to make sure that it's loaded on composer by run this command

```bash
composer dump-autoload
```

after create the plugin you can create a new table inside it and than run the migration generator to convert it to a migration file then you can use the GUI to generate resources, pages, widget or model, or you can easy use this commands

```bash
php artisan filament-plugins:model
php artisan filament-plugins:resource
php artisan filament-plugins:page
php artisan filament-plugins:widget
```

it will generate the files for you and you can use it directly, please note that you need to generate the model first than use other commands


## Publish Assets

you can publish config file by use this command
Expand Down
Binary file added arts/create-col.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added arts/generate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added arts/plugins.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added arts/table-cols.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added arts/tables.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 7 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"modules",
"HMVC",
"filament",
"plugins"
"plugins",
"generator"
],
"license": "MIT",
"autoload": {
Expand All @@ -36,7 +37,10 @@
}
],
"require": {
"php": "^8.0.2",
"tomatophp/console-helpers": "^1.0"
"php": "^8.1|^8.2",
"tomatophp/console-helpers": "^1.1",
"filament/filament": "^3.0.0",
"filament/notifications": "^3.0.0",
"nwidart/laravel-modules": "^11.0"
}
}
3 changes: 3 additions & 0 deletions config/filament-plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@
"allow_destroy" => true,
"allow_toggle" => true,
"allow_generator" => true,
"clusters" => [
"enabled" => true
]
];

3 changes: 3 additions & 0 deletions resources/views/pages/plugins.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<x-filament-panels::page>
{{ $this->table }}
</x-filament-panels::page>
69 changes: 69 additions & 0 deletions resources/views/pages/table.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 p-4">
@foreach($records as $item)
<div class="bg-white border border-gray-100 dark:border-gray-700 overflow-hidden dark:bg-gray-800 rounded-lg flex flex-col shadow-sm" >

@if($item['placeholder'] !== 'placeholder.webp')
<div class="h-40 overflow-hidden">
<img class="bg-cover bg-center" onerror="this.onerror=null; this.src='{{url('placeholder.webp')}}'" src="{{$item['placeholder']}}" />
</div>
@else
<div class="overflow-hidden flex flex-col rounded-t-lg justify-center items-center" style="background-color: {{$item['color']}}; height: 150px;">
<div>
<x-icon name="{{$item['icon']}}" class="text-white w-12 h-16" />
</div>
</div>
@endif
<div class="flex justifiy-between gap-4 px-4 my-2">
<div class="w-full">
<h1 class="font-bold">{{ json_decode($item['name'])->{app()->getLocale()} }}</h1>
</div>
<div>
<h1>{{ $item['version'] }}</h1>
</div>
</div>
<div class="h-30 px-4">
<p class="text-gray-600 dark:text-gray-300 text-sm h-30 truncate ...">
{{ json_decode($item['description'])->{app()->getLocale()} }}
</p>
</div>
<div class="flex justifiy-between gap-1 my-4 px-4 border-t border-gray-100 dark:border-gray-700 pt-4">
<div class="flex justifiy-start w-full gap-2">
@if((bool)config('filament-plugins.allow_generator'))
<x-filament::icon-button tooltip="Generate" tag="a" href="{{route('filament.'.filament()->getCurrentPanel()->getId().'.resources.tables.index', ['module'=>$item->module_name])}}">
<x-slot name="icon">
<x-heroicon-s-cog class="w-5 h-5" />
</x-slot>
</x-filament::icon-button>
@endif
@if((bool)config('filament-plugins.allow_toggle'))
@if($item->active)
{{ ($this->disableAction)(['item' => $item]) }}
@else
{{ ($this->activeAction)(['item' => $item]) }}
@endif

@endif
@if((bool)config('filament-plugins.allow_destroy'))
{{ ($this->deleteAction)(['item' => $item])}}
@endif
</div>
<div class="w-full flex justify-end gap-4">
@if($item->github)
<x-filament::icon-button tooltip="Github" href="{{$item->github}}" target="_blank" tag="a">
<x-slot name="icon">
<x-heroicon-s-globe-asia-australia class="w-5 h-5" />
</x-slot>
</x-filament::icon-button>
@endif
@if($item->docs)
<x-filament::icon-button tooltip="Docs" href="{{$item->docs}}" target="_blank" tag="a">
<x-slot name="icon">
<x-heroicon-s-document-text class="w-5 h-5" />
</x-slot>
</x-filament::icon-button>
@endif
</div>
</div>
</div>
@endforeach
</div>
Loading

0 comments on commit 3d39c2c

Please sign in to comment.