Code Monkey home page Code Monkey logo

filament-nested-resources's People

Contributors

acepoblete avatar blackpig avatar brentkelly avatar danilogiacomi avatar george-raphael avatar jamessessford avatar lukas-frey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

filament-nested-resources's Issues

[Bug]: scope to tenant not respected on nested resource

What happened?

When I create a record of a nested resource - in this case a page which is nested to a document - I get a 500 error as team_id isn't present on the nested resource table.

Documents are scoped to tenants but pages don't have to be as they belong to documents.

How to reproduce the bug

Create a resource and a nested resource. Set scopedToTenant as false on the nested resource.

Package Version

1.0.0

PHP Version

8.3

Laravel Version

10

Which operating systems does with happen with?

macOS

Notes

I may be using the package wrong and if so please let me know what I should've done differently.

Thanks for an excellent plugin!

[Bug]: can't get parent model id

What happened?

I should be able to get parent model to perform some queries
I did't find a way to get it while createing new nasted record

How to reproduce the bug

can't get parent model id

Package Version

1.0.0-alpha.8

PHP Version

8.2

Laravel Version

10.0

Which operating systems does with happen with?

No response

Notes

No response

[Bug]: Ancestor duplicate query

What happened?

Query by ancestor is many duplicated.

public function getRelatedRecord(Model $record): ?Model
{
$relationship = $this->getInverseRelationship($record);

return $relationship->first();

}

i got this from AI and then its reduce 50% duplicated query

How to reproduce the bug

Just using debugbar and initialize nested resource like in filament page

Package Version

newest

PHP Version

8.1

Laravel Version

10

Which operating systems does with happen with?

Windows

Notes

No response

[Bug]: Global search on root resources throws exception

What happened?

Using global search on a root resource throws an error.

How to reproduce the bug

Configure a column to be globally searchable on the root resource. Then search for a record in that resource.

Package Version

1.0.0-alpha.6

PHP Version

^8.1

Laravel Version

^10

Which operating systems does with happen with?

No response

Notes

I'm not sure if this is a user error or not. When I set up my root resource I didn't override the getAncestors method; it still returns null. So, when the getGlobalSearchResultUrl method is called on the NestedResource and it tries to search through its ancestors for their ids things blow up.

[Bug]: Looks like no support for manyToMany

What happened?

I have three tables
-campaigns (with id column)
-teams (with id column)
-campaigns_teams (pivot table with two foreign keys)

Now, I have a belongsToMany relationship set up on both Models, but I am getting an error when using this package.

Here is the error

Guava\Filament\NestedResources\Ancestor::getRelatedModel(): Return value must be of type Illuminate\Database\Eloquent\Model, Illuminate\Database\Eloquent\Collection returned

How to reproduce the bug

Create any many-to-many relationship and test this package.

Package Version

v3.0.0-alpha8

PHP Version

8.1

Laravel Version

10

Which operating systems does with happen with?

No response

Notes

No response

[Bug]: ManageRelatedRecords pages have blank ancestor route paramaters

What happened?

My resource has a couple subnav items through ManageRelatedRecords, the links in the subnav are missing the resource's root parameter causing a 404. However, the routes themselves are fine and can be accessed otherwise.

How to reproduce the bug

https://filamentphp.com/docs/3.x/panels/resources/getting-started#resource-sub-navigation

  1. Create resource sub navigation and relation page
  2. Click on the subnav

Package Version

1.0.0-alpha.9

PHP Version

8.3

Laravel Version

10

Which operating systems does with happen with?

Linux

Notes

No response

[Bug]: 404 on all nested relation pages

What happened?

I get 404 error on /projects/1/tests and /projects/1/tests/create. I did everything according to the documentation and checked twice. Also the routes are listed in route:list

  GET|HEAD  app.mysite.test/projects/{record} .................................................................................................................................................................... filament.app.resources.projects.view › App\Filament\App\Resources\ProjectResource\Pages\ViewProject
  GET|HEAD  app.mysite.test/projects/{record}/tests ...................................................................................................................................................... filament.app.resources.projects.tests › App\Filament\App\Resources\ProjectResource\Pages\ManageProjectTests
  GET|HEAD  app.mysite.test/projects/{record}/tests/create ......................................................................................................................................... filament.app.resources.projects.tests.create › App\Filament\App\Resources\ProjectResource\Pages\CreateProjectTest

How to reproduce the bug

I tried the same with a different resource but the issue persists. I do not use any other traits or packages with my filament resources involved.

Package Version

1.0

PHP Version

8.2

Laravel Version

10.10

Which operating systems does with happen with?

macOS, Linux

Notes

Any ideas on how to investigate this further?

[Bug]: Incorrect urls generated when primaryKey is not "id"

What happened?

I have a database where primaryKeys aren't "id", but "nID"

I can do laravel work with it simply using this statement in models:
protected $primaryKey = 'nID';

But when using nested-resources the urls that are generated doesn't have the parent levels nIDs on it (two slashes appear together)

I was guessing that the package assumes that primary key will be "id" and this returns a null value on my instances, so I tested a workaround in my models:

public function getIdAttribute()  {
    return $this->nID;
}

and it worked!

I hope this will help debuging the alfa package.

How to reproduce the bug

If you create or use a database with non-id primary keys you will experience the issue simply making a nested resource.

Package Version

1.0@alpha

PHP Version

8.1.8

Laravel Version

10.10

Which operating systems does with happen with?

No response

Notes

No response

[Bug]: not working with SLUG keyed models

What happened?

I am using models keyed by slug .. not by ID

when I acces root resource on url "http://localhost:8000/admin/categories/tocene-pivo"

button linkt to create new child item is "http://localhost:8000/admin/categories//items/create?category=tocene-pivo"
there is missing model slug "tocene-pivo" between categories and items

when I manualy try go to adress using slug "http://localhost:8000/admin/categories/tocene-pivo/items/create?category=tocene-pivo",
there is error
error

when I try manualy go to adress using ID "http://localhost:8000/admin/categories/1/items/create?category=tocene-pivo"
this adress work, but in adress and breadcrumbs is ID, instead of slug .. which is bad :(

How to reproduce the bug

use laravel models keyed by slug

Package Version

1.0.0-alpha.4

PHP Version

8.2.11

Laravel Version

10.28.0

Which operating systems does with happen with?

Windows

Notes

No response

[Bug]: Unable to get nested Create to work in new release

What happened?

I had successfully implements an earlier version of this package. I was now trying to migrate to the 1.0.0 version. But i am not able to manage this yet.

Is there a example of the RelationManager implementation?

I would say i followed the steps of the documentation, but still have some issues.
Edit of a nested resource is now working. But it has a not nested url. Is this an intendent change or or am i missing some configuration?
Create is redirecting to a nested url but it is showing an 404 while the route is registered in laravel.

Looks like I'm missing some information. Could you help me to get it to work and probably improve the documentation for others as well?

How to reproduce the bug

class ArtistResource extends Resource
{
    use NestedResource;

    public static function getAncestor(): ?Ancestor
    {
        return null;
    }
    
    public static function getRelations(): array
    {
        return [
            ArtistAlbumRelationManager::class,
        ];
    }
   //...

    public static function getPages(): array
    {
        return [
            'index' => Pages\ListArtists::route('/'),
            'create' => Pages\CreateArtist::route('/create'),
            'edit' => Pages\EditArtist::route('/{record}/edit'),
            'albums.create' => CreateArtistAlbum::route('/{record}/albums/create'),
        ];
    }
}
class ArtistAlbumResource extends Resource
{
    use NestedResource;

    public static function getAncestor(): ?Ancestor
    {
        return Ancestor::make('albums', 'artist');
    }
   //...
    
    public static function getPages(): array
    {
        return [
            'edit' => Pages\EditArtistAlbum::route('/{record}/edit'),
        ];
    }
}
class CreateArtistAlbum extends CreateRelatedRecord
{
    use NestedPage;
   //...
 }
class EditArtistAlbum extends EditRecord
{
    use NestedPage;
   //...
}
class ArtistAlbumsRelationManager extends RelationManager
{
    use NestedRelationManager;
    //...
}

Package Version

1.0.0

PHP Version

8.3.0

Laravel Version

11

Which operating systems does with happen with?

No response

Notes

No response

[Bug]: getRelationship() using getModelLabel()

What happened?

I want to use the getModelLabel() function to set my translated labels, without interfering with this package.

How to reproduce the bug

The class Ancestor has the following function to get the relationship:

Ancestor.php

    public function getRelationship(): string
    {
        if (! $this->relationship) {
            return $this->getResource()::getModelLabel();
        }

        return $this->relationship;
    }

Problem is, I'm using getModelLabel to translate the navigation items, as suggested by the Filament documentation...
Filament example
afbeelding
My code

    public static function getModelLabel(): string
    {
        return ___('signeditor.signs', 1);
    }

...which results in the relationship sign() being translated into Bord(), which does not exist 😛
afbeelding

Package Version

1.0.0-alpha.5

PHP Version

8.2.11

Laravel Version

10.30.0

Which operating systems does with happen with?

Linux

Notes

No response

[Bug]: Cannot install via composer

What happened?

I cannot install package via composer - error
Could not find a version of package guava/filament-nested-resources matching your minimum-stability (stable). Require it with an explicit version constraint allowing its desired stability.

composer.json

    "name": "laravel/laravel",
    "type": "project",
    "description": "The skeleton application for the Laravel framework.",
    "keywords": [
        "laravel",
        "framework"
    ],
    "license": "MIT",
    "require": {
        "php": "^8.1",
        "amocrm/amocrm-api-library": "^1.4",
        "awcodes/filament-tiptap-editor": "^3.0",
        "codewithdennis/filament-select-tree": "^3.1",
        "filament/filament": "^3.0-stable",
        "guzzlehttp/guzzle": "^7.2",
        "laravel/framework": "^10.10",
        "laravel/sanctum": "^3.3",
        "laravel/scout": "^10.6",
        "laravel/tinker": "^2.8",
        "mohamedsabil83/filament-forms-tinyeditor": "^2.2",
        "spatie/laravel-sitemap": "^7.0"
    },
    "require-dev": {
        "fakerphp/faker": "^1.9.1",
        "laravel/breeze": "^1.26",
        "laravel/envoy": "^2.8",
        "laravel/pint": "^1.0",
        "laravel/sail": "^1.26",
        "mockery/mockery": "^1.4.4",
        "nunomaduro/collision": "^7.0",
        "phpunit/phpunit": "^10.1",
        "spatie/laravel-ignition": "^2.0"
    },
    "autoload": {
        "psr-4": {
            "App\\": "app/",
            "Database\\Factories\\": "database/factories/",
            "Database\\Seeders\\": "database/seeders/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi",
            "@php artisan filament:upgrade"
        ],
        "post-update-cmd": [
            "@php artisan vendor:publish --tag=laravel-assets --ansi --force"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true,
        "allow-plugins": {
            "pestphp/pest-plugin": true,
            "php-http/discovery": true
        }
    },
    "minimum-stability": "stable",
    "prefer-stable": true
}

How to reproduce the bug

composer require guava/filament-nested-resources

Package Version

2

PHP Version

8.2.0

Laravel Version

10

Which operating systems does with happen with?

No response

Notes

No response

[Bug]: page actions are missing route params

What happened?

When you go to the view page, you can't click on the edit button because the URL is missing the parent of the nested resources URL param.

How to reproduce the bug

Create a nested resource. Navigate to a child resources' view page. Click on the edit button and you get a 404. If you are on the a edit page, the view button will take you to a 404 page too.

Package Version

1.0.0-alpha.5

PHP Version

8.1.24

Laravel Version

10.10

Which operating systems does with happen with?

macOS

Notes

No response

[Bug]: When view is enabled the breadcrumbs link is still to edit page...

What happened?

I think that if we have a view page, the breadcrumbs should link to the view page (which is the default for clicking on the record itself), not the edit link that it is currently linking to.

Is there any way to overwrite it?

How to reproduce the bug

just make a nested rescource with the --view flag

Package Version

3.x

PHP Version

8.3

Laravel Version

10

Which operating systems does with happen with?

No response

Notes

No response

[Bug]: Can't install the package

What happened?

composer require guava/filament-nested-resources

In PackageDiscoveryTrait.php line 331:

Could not find a version of package guava/filament-nested-resources matching your minimum-stability (stable). Require it with an explicit version cons
traint allowing its desired stability.

require [--dev] [--dry-run] [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--fixed] [--no-suggest] [--no-progress] [--no-update] [--no-install] [--no-audit] [--audit-format AUDIT-FORMAT] [--update-no-dev] [-w|--update-with-dependencies] [-W|--update-with-all-dependencies] [--with-dependencies] [--with-all-dependencies] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--] [...]

How to reproduce the bug

i had to use composer require guava/filament-nested-resources:dev-main instead

Package Version

default

PHP Version

8.2.1

Laravel Version

10

Which operating systems does with happen with?

No response

Notes

No response

[Bug]: getBreadcrumbs gives error when a field is refreshing

What happened?

If a field is live, when it is updated in a CreateRelatedRecord a "Typed property Guava\FilamentNestedResources\Pages\CreateRelatedRecord::$record must not be accessed before initialization" error is raised.

How to reproduce the bug

Set a field as live() and change its status.

Package Version

1.0.0-beta.3

PHP Version

8.2.16

Laravel Version

10.48.3

Which operating systems does with happen with?

No response

Notes

Changing
$record = $this->record
with
$record = isset($this->record)
? $this->record
: $this->getOwnerRecord();
resolved the problem for me

[Bug]: Error when using morph relation

What happened?

I got an error when using morph relation:
Guava\Filament\NestedResources\Ancestor::getRelatedModel(): Return value must be of type Illuminate\Database\Eloquent\Model, null returned

How to reproduce the bug

Use these relevant codes, and try to open the edit program page, and it will be an error.

Relevant codes:

class Program extends Model
{
    public function groups(): MorphMany
    {
        return $this->morphMany(Group::class, 'groupable', 'groupable_type', 'groupable_id', 'id');
    }
}

class Group extends Model
{
    public function groupable(): MorphTo
    {
        return $this->morphTo('groupable', 'groupable_type', 'groupable_id', 'id');
    }
}

class ProgramResource extends NestedResource
{
    protected static ?string $model = Program::class;

    public static function getRelations(): array
    {
        return [
            RelationManagers\GroupsRelationManager::class,
        ];
    }
}

class GroupsRelationManager extends NestedRelationManager
{
    protected static string $relationship = 'groups';

    public function form(Form $form): Form
    {
        return GroupResource::form($form);
    }

    public function table(Table $table): Table
    {
        return GroupResource::table($table);
    }
}

class GroupResource extends NestedResource
{
    protected static ?string $model = Group::class;

    public static function getAncestor(): ?Ancestor
    {
        // This is just a simple configuration with a few helper methods
        return Ancestor::make(
            ProgramResource::class, // Parent Resource Class
            // Optionally you can pass a relationship name, if it's non-standard. The plugin will try to guess it otherwise
            'groupable'
        );
    }
}

class CreateGroup extends NestedCreateRecord
{
    protected static string $resource = GroupResource::class;
}

class EditGroup extends NestedEditRecord
{
    protected static string $resource = GroupResource::class;
}

class ListGroups extends NestedListRecords
{
    protected static string $resource = GroupResource::class;
}

Package Version

1.0.0-alpha.5

PHP Version

8.2.10

Laravel Version

10

Which operating systems does with happen with?

No response

Notes

No response

[Bug]: getTableQuery in list view of child resources are not filtered.

What happened?

When you are loading up the list view table, you see every record in the database instead of the records being filtered by their parent record.

How to reproduce the bug

Create a root resource and a corresponding child resource in your app. Create two root records RootA and RootB. On record A, navigate to the child resource and create a new record ChildA. Attempt to do the same for RootB. You will notice that when you are on the child resource for RootB, you will see that ChildA is visible in the table.

Package Version

1.0.0-alpha.8

PHP Version

8.1

Laravel Version

10

Which operating systems does with happen with?

No response

Notes

I think the getTableQuery method needs to be extended in the NestedResource class.

[Bug]: Create modal causes route not found error

What happened?

When you have a nested resource that does not have a create page, the create action on the list page causes a route not found error.

How to reproduce the bug

Create a nested resource then comment out the create page route.

Package Version

1.0.0-alpha.7

PHP Version

8.2

Laravel Version

10

Which operating systems does with happen with?

No response

Notes

I think the solution is to check to see if there is a create page on the resource before setting the action URL on the configureCreateAction method.

if (static::getResource()::hasPage('create')) { $action->url(static::getResource()::getUrl('create', $this->getRouteParameterIds())); }

[Bug]: CreateRelatedRecord and Translatable

What happened?

Hi, I have a CreateRelatedRecord which uses the official Spatie Translatable plugin (https://filamentphp.com/plugins/filament-spatie-translatable).

How can I implement this for the CreateRelatedRecord? I can't add the LocaleSwitcher to the CreateRelatedRecord class, because the ParentResource doesn't have any translations.

How to reproduce the bug

Have a nested resource where the nested resource has translatable properties.

ParentResource -> NestedResource (use Translatable)

Package Version

1.0.0-beta.3

PHP Version

8.3.3

Laravel Version

10.10

Which operating systems does with happen with?

macOS

Notes

No response

[Bug]: ForceDeleteAction generates error on NestedEditRecord class

What happened?

When using SoftDeletes, ForceDeleteAction asks for an index route

How to reproduce the bug

Use a Resource with --soft-delete enabled as Child.

Package Version

1.0.0-alpha.8

PHP Version

8.3.0

Laravel Version

10.10

Which operating systems does with happen with?

macOS

Notes

No response

[Bug]: Access to undeclared static property App\Filament\Resources\CourseResource\Pages\CreateCourseLesson::$relationship

What happened?

When I am trying to navigate to the create page I am getting the below error.

Access to undeclared static property App\Filament\Resources\CourseResource\Pages\CreateCourseLesson::$relationship

This is the content of my CourseResource\Pages\CreateCourseLesson.php file.

<?php

namespace App\Filament\Resources\CourseResource\Pages;

use App\Filament\Resources\CourseResource;
use Guava\FilamentNestedResources\Concerns\NestedPage;
use Guava\FilamentNestedResources\Pages\CreateRelatedRecord;

class CreateCourseLesson extends CreateRelatedRecord
{
    use NestedPage;

    protected static string $resource = CourseResource::class;

}

Did I miss something here?

How to reproduce the bug

When creating lesson from the relation page.

Package Version

1.0

PHP Version

8.3

Laravel Version

11

Which operating systems does with happen with?

macOS

Notes

No response

[Bug]: Unabled to get nested relation appear in the create/edit form

What happened?

I am unable to get nested relationship working despite following the readme, as well as the example https://github.com/GuavaCZ/filament-nested-resources-demo

Here is a gist showing my resource config: https://gist.github.com/skills-up/95e0fb477bbe03972d5e4c46cb1fedb5

How to reproduce the bug

Generate the resource using command line.
Modify pages to include NestedPage trait.
Create additional pages with NestedPage and NestedRelationManager traits.

Package Version

1.0.1

PHP Version

8.2.18

Laravel Version

11.9.2

Which operating systems does with happen with?

macOS

Notes

No response

[Bug]: route params are not removed from the name of the route.

What happened?

When generating the name of a nested resource route, the route params not not removed.

How to reproduce the bug

Create a nested resource and run php artisan route:list. Routes names will look like this filament.admin.resources.projects.{projectRecord?}.subcontractor-contracts.edit instead of this filament.admin.resources.projects.subcontractor-contracts.edit.

Package Version

1.0.0-alpha.5

PHP Version

8.1.24

Laravel Version

^10.10

Which operating systems does with happen with?

macOS

Notes

No response

[Bug]: complexCamelCaseModels will break the routes

What happened?

I see a 404 error when nesting resources with LongCamelCaseNames.

How to reproduce the bug

For example I have a model named ProjectSpNature (with the resource named ProjectSpNatureResource) and the generated route as per artisan route:list is

admin/projects/{projectRecord?}/project-sp-natures/{project sp natureRecord?}/building-blocks/create

instead of

admin/projects/{projectRecord?}/project-sp-natures/{projectSpNatureRecord?}/building-blocks/create

This creates a 404 error probably because of the spaces inside the parameter

Package Version

1.0.0-alpha.5

PHP Version

8.2.12

Laravel Version

10.30.1

Which operating systems does with happen with?

macOS

Notes

I think the solution could be changing the helper function that gets the route parameter

from

if (! function_exists('Guava\Filament\NestedResources\get_model_route_parameter')) {
    function get_model_route_parameter(string | Model $model): string
    {
        return get_model_label(is_string($model) ? $model : $model::class) . 'Record';
    }
}

to

if (! function_exists('Guava\Filament\NestedResources\get_model_route_parameter')) {
    function get_model_route_parameter(string | Model $model): string
    {
        return Str::camel(get_model_label(is_string($model) ? $model : $model::class)) . 'Record';
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.