Hammerstone Refine has not launched yet. Sign up for the early access list to stay up to date!
In Laravel, when you are creating a polymorphic relationship, you have the opportunity to set up a
morphMap. From the Laravel docs:
By default, Laravel will use the fully qualified class name to store the type of the related model. For instance, given the one-to-many example above where a Comment may belong to a Post or a Video, the default commentable_type would be either App\Post or App\Video, respectively.
However, you may wish to decouple your database from your application's internal structure. In that case, you may define a "morph map" to instruct Eloquent to use a custom name for each model instead of the class name:
Which looks like this:
1use Illuminate\Database\Eloquent\Relations\Relation;23Relation::morphMap([4 'posts' => 'App\Post',5 'videos' => 'App\Video',6]);
In the same way, when you are stabilizing your filters, Hammerstone will use the fully qualified class name to represent the type of filter that is being stored. This could cause problems in the future should you ever want to rename or move the filter class.
For that reason, it's recommended that you register a filter under a key that is not the class name. You can do that by calling the
register method on the base filter. A good place to do this would be in a service provider:
1Filter::register([2 'employees' => EmployeeFilter::class,3]);
Now you're free to move or rename the
EmployeeFilter class without invalidating all the stored filters you may have.