Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[V4] MediaResource should get the Media model from the config #632

@ezalorpro

Description

@ezalorpro

Filament Version

v4.1.7

Plugin Version

v4

PHP Version

PHP 8.3

Problem description

Error:

The model [Awcodes\Curator\Models\Media] does not have a relationship named [event]. You can change the relationship being used by passing it to the [ownershipRelationship] argument of the [tenant()] method in configuration. You can change the relationship being used per-resource by setting it as the [$tenantOwnershipRelationshipName] static property on the [App\Filament\Resources\Media\MediaResource] resource class.

Image

( event is my tenant relationship )

Expected behavior

Should work correctly with tenant enable and a custom Media model that extends the base Media model with a tenant relationship,

in the MediaResource.php file, line 24, there is this line in V4

protected static ?string $model = Media::class;

like in V3, should be ( i think ):

public static function getModel(): string { return config('curator.model'); }

Steps to reproduce

  • Install curator V4 with tenancy
  • enable tenancy in the curator config with the proper relationship
  • Set the custom Media model auto generated by the installer in the curator config "model"
  • Use the CuratorPicker

Reproduction repository

No response

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions