Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: add pint and actions #19

Merged
merged 1 commit into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/fix-php-code-style-issues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Fix PHP code style issues

on:
pull_request:
branches: [main]
types: [closed]

jobs:
php-code-styling:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}

- name: Fix PHP code style issues
uses: aglipanci/[email protected]

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Fix styling
118 changes: 118 additions & 0 deletions .idea/blade.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/filament-quick-create.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/laravel-idea.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"require": {
"php": "^8.0.2",
"filament/filament": "^2.0",
"laravel/pint": "^1.2",
"spatie/laravel-package-tools": "^1.9.2"
},
"autoload": {
Expand All @@ -44,6 +45,9 @@
"preferred-install": "dist",
"sort-packages": true
},
"scripts": {
"pint": "pint"
},
"minimum-stability": "dev",
"prefer-stable": true
}
}
68 changes: 67 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/Facades/QuickCreate.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*
* @see \FilamentQuickCreate\QuickCreate
*/

class QuickCreate extends Facade
{
/**
Expand Down
12 changes: 5 additions & 7 deletions src/FilamentQuickCreateServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function configurePackage(Package $package): void
->hasConfigFile()
->hasViews();
}

public function packageRegistered(): void
{
$this->app->scoped(Facade::class, function () {
Expand All @@ -35,7 +35,7 @@ public function boot()
Filament::registerRenderHook(
'global-search.end',
fn (): View => view('filament-quick-create::components.create-menu', [
'items' => $this->getFilamentResources()
'items' => $this->getFilamentResources(),
]),
);

Expand All @@ -50,23 +50,21 @@ public function getFilamentResources(): array
})
->map(function ($resource) {
$resource = App::make($resource);
$route = $resource->getRouteBaseName() . '.create';
$route = $resource->getRouteBaseName().'.create';
if ($resource->canCreate() && Route::has($route)) {
return [
'label' => Str::ucfirst($resource->getModelLabel()),
'icon' => invade($resource)->getNavigationIcon(),
'url' => route($route)
'url' => route($route),
];
}

return null;
})
->when(Facade::sortingEnabled(), fn($collection) => $collection->sortBy('label'))
->when(Facade::sortingEnabled(), fn ($collection) => $collection->sortBy('label'))
->values()
->toArray();

return array_filter($resources);
}


}
13 changes: 8 additions & 5 deletions src/QuickCreate.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,21 @@
use Closure;
use Filament\Facades\Filament;

class QuickCreate {

class QuickCreate
{
public Closure $getResourcesUsing;

public bool $sort = true;

public function __construct()
{
$this->getResourcesUsing(fn() => Filament::getResources());
$this->getResourcesUsing(fn () => Filament::getResources());
}

public function sort(bool $sort): static
{
$this->sort = $sort;

return $this;
}

Expand All @@ -30,9 +31,10 @@ public function sortingEnabled(): bool
public function getResourcesUsing(Closure $callback): static
{
$this->getResourcesUsing = $callback;

return $this;
}

public function evaluate($value, array $parameters = [])
{
if ($value instanceof Closure) {
Expand All @@ -41,11 +43,12 @@ public function evaluate($value, array $parameters = [])
$parameters
);
}

return $value;
}

public function getResources(): array
{
return $this->evaluate($this->getResourcesUsing);
}
}
}