Hello,
I have no recipe model, my recipes are just a jsonable variable (repeater) in my Menu model.
I tried to apply what you suggest, before I had a $hasOne relation in my Menu model like this :
public $hasOne = [
'category' => ['Troiscent\Menus\Models\Category']
];
It worked well in the backoffice, I could select the category in a dropdown in the "recipes" repeater, and the category ID correctly saved in the "recipes" $jsonable variable in the database.
Now, I changed the $hasOne relation like this :
public $belongsTo = [
'category' => ['Troiscent\Menus\Models\Category']
];
And I added a relation in the Category Model like this :
public $hasMany = [
'recipes' => ['Troiscent\Menus\Models\Menu']
];
But I don't see any changes compared as before. It still work in the backend, I can select my category in a dropdown in my repeater, it's correctly saved in the database. But {{ recipe.category.title }} still return nothing (and recipe.cateogy return the category ID).
I'm not sure if I defined the relations correctly. It works, but as my relation is in a repeater, I need to do some more things to "keep the relation" between my recipes and my categories.
If you have some suggestions
Thanks