Feature(s) impacted
Collection name
Observed behavior
I have several weird collections name :
- a table named “analytics_basket” > Collection name : “Baskets” (but I have also a “basket” table which I can’t see in collections)
- a table named “order_counter_offer” > Collection name : “Counter offers” : why “Order” disappeared ? I have also a table named “order_delivery” > Collection name “Order Deliveries” : name is OK
Expected behavior
- table name “analytics_basket” > Collection name “Analytics Baskets”
- table name “order_counter_offer” > Collection name “Order Counter Offers”
More generally, I don’t understand why, in “COLLECTION SETTINGS”, in the field “name” it’s already a modified name. Like “counterOffer” for my table “order_counter_offer”. Why not the exact table name since there is “Display name” field ?
Failure Logs
N/A
Context
MySQL Database : 8.0.22
Laravel Forest Admin package : 1.0.1
Hi @storm23,
I’m not sure about your issue.
When you said table named “analytics_basket” is there a Model that reference this table ? If yes what is the name of this model class ?
The Forest agent lists only the laravel models not all your database tables.
Also could you share your project Id and the environment name.
Ok I got it ! The name is bases on the Model name, not the mapped table ? Right ?
It’ a problem for me because I have several namespaces in my Models. For example :
- MyApp\Models\Analytics\Basket => “analytics_basket” table
- MyApp\Models\Customer\Basket => “basket” table
Is there a way to handle these two tables ?
Yes this is the current behaviour of our agent.
Actually we have a feature that could help you.
You can try this feature by adding this line into your composer.json
"repositories": [
{
"type": "git",
"url": "https://github.com/ForestAdmin/laravel-forestadmin.git"
}
],
"require": {
...
"forestadmin/laravel-forestadmin": "dev-feat/multi-directories-models",
...
},
The config/forest.php
has been slightly changed.
You can remove the 'models_namespace'
key and replace 'models_directory' => env('MODEL_DIRECTORY', 'app/Models/')
by 'models_directory' => ['app/Models']
.
We have just updated it and now you can set a custom name on your collection.
First you need to use our trait ForestAdmin\LaravelForestAdmin\Services\Concerns\ForestCollection
into your models and set a custom name with the method forestName.
Then you need to update your .forestadmin-schema.json.
Example:
use ForestAdmin\LaravelForestAdmin\Services\Concerns\ForestCollection;
class Book extends Model
{
use ForestCollection;
public function forestName() {
return 'Comics';
}
1 Like
Hi @storm23 ,
This feature is now available in the latest version (v1.1.1) of laravel-forestadmin.