Skip to content
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
10 changes: 4 additions & 6 deletions .github/workflows/test-runner.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
name: Tests

on:
# Run testing on all push and pull requests for the main branch that have committed changes in PHP files
# Run testing on all push and pull requests that have committed changes in PHP files
push:
branches: [ "main" ]
paths:
- '**.php'
- '**/*.php'
pull_request:
branches: [ "main" ]
paths:
- '**.php'
- '**/*.php'
# Make it possible to run the workflow manually
workflow_dispatch:

Expand Down Expand Up @@ -68,7 +66,7 @@ jobs:

- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "filament/support:^3.3" --no-interaction --no-update
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --${{ matrix.dependency-version }} --prefer-dist --no-progress --no-interaction

- name: Run test suite
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@
},
"require": {
"php": "^8.2",
"bezhansalleh/filament-shield": "^3.3",
"bezhansalleh/filament-shield": "^4.0",
"datalinx/php-utils": "^2.5",
"eclipsephp/common": "dev-main",
"eclipsephp/world-plugin": "dev-main",
"filament/filament": "^3.3",
"filament/spatie-laravel-media-library-plugin": "^3.2",
"filament/spatie-laravel-translatable-plugin": "^3.2",
"filament/filament": "^4.0",
"filament/spatie-laravel-media-library-plugin": "^4.0",
"lara-zeus/spatie-translatable": "^1.0",
"laravel/framework": "^11.0|^12.0",
"nben/filament-record-nav": "^1.0",
"phpoffice/phpspreadsheet": "^1.30",
"solution-forest/filament-tree": "^2.1",
"solution-forest/filament-tree": "^3.0",
"spatie/laravel-package-tools": "^1.19",
"spatie/laravel-translatable": "^6.11"
},
Expand Down
86 changes: 86 additions & 0 deletions config/filament-shield.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php

return [
'shield_resource' => [
'slug' => 'shield/roles',
'show_model_path' => true,
'cluster' => null,
'tabs' => [
'pages' => true,
'widgets' => true,
'resources' => true,
'custom_permissions' => true,
],
],

'tenant_model' => \Eclipse\Core\Models\Site::class,

'auth_provider_model' => \Eclipse\Core\Models\User::class,

'super_admin' => [
'enabled' => true,
'name' => 'super_admin',
'define_via_gate' => false,
'intercept_gate' => 'before',
],

'panel_user' => [
'enabled' => true,
'name' => 'panel_user',
],

'permissions' => [
'separator' => '_',
'case' => 'lower_snake',
'generate' => true,
],

'policies' => [
'path' => app_path('Policies'),
'merge' => false,
'generate' => true,
'methods' => [
'viewAny', 'view', 'create', 'update', 'restore', 'restoreAny',
'replicate', 'reorder', 'delete', 'deleteAny', 'forceDelete', 'forceDeleteAny',
],
'single_parameter_methods' => [
'viewAny', 'create', 'deleteAny', 'forceDeleteAny', 'restoreAny', 'reorder',
],
],

'localization' => [
'enabled' => false,
'key' => 'filament-shield::filament-shield',
],

'resources' => [
'subject' => 'model',
'manage' => [],
'exclude' => [],
],

'pages' => [
'subject' => 'class',
'prefix' => 'view',
'exclude' => [
],
],

'widgets' => [
'subject' => 'class',
'prefix' => 'view',
'exclude' => [
],
],

'custom_permissions' => [
],

'discovery' => [
'discover_all_resources' => true,
'discover_all_widgets' => true,
'discover_all_pages' => true,
],

'register_role_policy' => true,
];
5 changes: 3 additions & 2 deletions src/Casts/BackgroundCast.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

use Eclipse\Catalogue\Values\Background;
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
use Illuminate\Database\Eloquent\Model;

class BackgroundCast implements CastsAttributes
{
/**
* Cast the attribute from the database.
*
* @param \Illuminate\Database\Eloquent\Model $model The model instance.
* @param Model $model The model instance.
* @param string $key The attribute name.
* @param mixed $value The attribute value.
* @param array $attributes The attributes array.
Expand All @@ -37,7 +38,7 @@ public function get($model, string $key, $value, array $attributes): Background
/**
* Cast the attribute to a database value.
*
* @param \Illuminate\Database\Eloquent\Model $model The model instance.
* @param Model $model The model instance.
* @param string $key The attribute name.
* @param mixed $value The attribute value.
* @param array $attributes The attributes array.
Expand Down
135 changes: 133 additions & 2 deletions src/CatalogueServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,23 @@

namespace Eclipse\Catalogue;

use Eclipse\Catalogue\Filament\Resources\CategoryResource;
use Eclipse\Catalogue\Filament\Resources\GroupResource;
use Eclipse\Catalogue\Filament\Resources\MeasureUnitResource;
use Eclipse\Catalogue\Filament\Resources\PriceListResource;
use Eclipse\Catalogue\Filament\Resources\ProductResource;
use Eclipse\Catalogue\Filament\Resources\ProductStatusResource;
use Eclipse\Catalogue\Filament\Resources\ProductTypeResource;
use Eclipse\Catalogue\Filament\Resources\PropertyResource;
use Eclipse\Catalogue\Filament\Resources\PropertyValueResource;
use Eclipse\Catalogue\Filament\Resources\TaxClassResource;
use Eclipse\Catalogue\Livewire\TenantSwitcher;
use Eclipse\Catalogue\Models\Category;
use Eclipse\Catalogue\Models\Product;
use Filament\Support\Assets\Css;
use Filament\Support\Facades\FilamentAsset;
use Illuminate\Support\Facades\Config;
use Livewire\Livewire;
use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;

Expand Down Expand Up @@ -44,9 +56,128 @@ public function boot()
{
parent::boot();

// Merge per-resource abilities into the effective config
$this->app->booted(function () {
$manage = config('filament-shield.resources.manage', []);

$pluginManage = [
ProductResource::class => [
'viewAny',
'view',
'create',
'update',
'restore',
'restoreAny',
'delete',
'deleteAny',
'forceDelete',
'forceDeleteAny',
],
CategoryResource::class => [
'viewAny',
'view',
'create',
'update',
'restore',
'restoreAny',
'delete',
'deleteAny',
'forceDelete',
'forceDeleteAny',
],
ProductTypeResource::class => [
'viewAny',
'view',
'create',
'update',
'restore',
'restoreAny',
'delete',
'deleteAny',
'forceDelete',
'forceDeleteAny',
],
PropertyResource::class => [
'viewAny',
'view',
'create',
'update',
'delete',
'deleteAny',
'forceDelete',
'forceDeleteAny',
'restore',
'restoreAny',
],
PropertyValueResource::class => [
'viewAny',
'view',
'create',
'update',
'delete',
'deleteAny',
],
GroupResource::class => [
'viewAny',
'view',
'create',
'update',
'delete',
'deleteAny',
],
PriceListResource::class => [
'viewAny',
'view',
'create',
'update',
'restore',
'restoreAny',
'delete',
'deleteAny',
'forceDelete',
'forceDeleteAny',
],
MeasureUnitResource::class => [
'viewAny',
'view',
'create',
'update',
'restore',
'restoreAny',
'delete',
'deleteAny',
'forceDelete',
'forceDeleteAny',
],
TaxClassResource::class => [
'viewAny',
'view',
'create',
'update',
'restore',
'restoreAny',
'delete',
'deleteAny',
'forceDelete',
'forceDeleteAny',
],
ProductStatusResource::class => [
'viewAny',
'view',
'create',
'update',
'delete',
'deleteAny',
],
];

$manage = array_replace_recursive($manage, $pluginManage);
config()->set('filament-shield.resources.manage', $manage);
});

// Register Livewire components
if (class_exists(\Livewire\Livewire::class)) {
\Livewire\Livewire::component('eclipse-catalogue::tenant-switcher', \Eclipse\Catalogue\Livewire\TenantSwitcher::class);
if (class_exists(Livewire::class)) {
Livewire::component('eclipse-catalogue::tenant-switcher', TenantSwitcher::class);
}

FilamentAsset::register([
Expand Down
5 changes: 3 additions & 2 deletions src/Factories/ProductTypeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Eclipse\Catalogue\Factories;

use Eclipse\Catalogue\Models\ProductType;
use Eclipse\Core\Models\Locale;
use Illuminate\Database\Eloquent\Factories\Factory;

class ProductTypeFactory extends Factory
Expand Down Expand Up @@ -35,8 +36,8 @@ public function definition(): array
*/
protected function getAvailableLocales(): array
{
if (class_exists(\Eclipse\Core\Models\Locale::class)) {
return \Eclipse\Core\Models\Locale::getAvailableLocales()
if (class_exists(Locale::class)) {
return Locale::getAvailableLocales()
->pluck('id')
->toArray();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Eclipse\Catalogue\Filament\Filters\Operators;

use Filament\Forms\Components\Component;
use Filament\Forms\Components\TextInput;
use Filament\Tables\Filters\QueryBuilder\Constraints\Operators\Operator;
use Illuminate\Database\Eloquent\Builder;
Expand Down Expand Up @@ -48,7 +47,7 @@ public function getSummary(): string
/**
* Get the form schema of the operator.
*
* @return array<Component>
* @return array<\Filament\Schemas\Components\Component>
*/
public function getFormSchema(): array
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Eclipse\Catalogue\Filament\Filters\Operators;

use Filament\Forms\Components\Component;
use Filament\Forms\Components\TextInput;
use Filament\Tables\Filters\QueryBuilder\Constraints\Operators\Operator;
use Illuminate\Database\Eloquent\Builder;
Expand Down Expand Up @@ -48,7 +47,7 @@ public function getSummary(): string
/**
* Get the form schema of the operator.
*
* @return array<Component>
* @return array<\Filament\Schemas\Components\Component>
*/
public function getFormSchema(): array
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Eclipse\Catalogue\Filament\Filters\Operators;

use Filament\Forms\Components\Component;
use Filament\Forms\Components\TextInput;
use Filament\Tables\Filters\QueryBuilder\Constraints\Operators\Operator;
use Illuminate\Database\Eloquent\Builder;
Expand Down Expand Up @@ -48,7 +47,7 @@ public function getSummary(): string
/**
* Get the form schema of the operator.
*
* @return array<Component>
* @return array<\Filament\Schemas\Components\Component>
*/
public function getFormSchema(): array
{
Expand Down
Loading