Skip to content

Commit

Permalink
Merge pull request #6 from ArtMin96/exclude-resource
Browse files Browse the repository at this point in the history
Allow to exclude resources
  • Loading branch information
awcodes authored Jul 21, 2022
2 parents 2b5f6fa + ed9d5d1 commit 92a9885
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
7 changes: 7 additions & 0 deletions config/filament-quick-create.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

return [
'exclude' => [
//
]
];
31 changes: 19 additions & 12 deletions src/FilamentQuickCreateServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public function configurePackage(Package $package): void
{
$package
->name('filament-quick-create')
->hasConfigFile()
->hasViews();
}

Expand All @@ -34,18 +35,24 @@ public function boot()

public function getFilamentResouces()
{
$resources = array_map(function($resource) {
$resource = App::make($resource);
$route = $resource->getRouteBaseName() . '.create';
if ($resource->canCreate() && Route::has($route)) {
$navItems = $resource->getNavigationItems();
return [
'label' => Str::title($resource->getModelLabel()),
'icon' => $navItems[0]->getIcon(),
'url' => route($route)
];
}
}, Filament::getResources());
$resources = collect(Filament::getResources())
->filter(function ($resource) {
return ! in_array($resource, config('filament-quick-create.exclude'));
})
->map(function ($resource) {
$resource = App::make($resource);
$route = $resource->getRouteBaseName() . '.create';
if ($resource->canCreate() && Route::has($route)) {
$navItems = $resource->getNavigationItems();
return [
'label' => Str::title($resource->getModelLabel()),
'icon' => $navItems[0]->getIcon(),
'url' => route($route)
];
}
})
->values()
->toArray();

return array_filter($resources);
}
Expand Down

0 comments on commit 92a9885

Please sign in to comment.