BREAD
Hello Bobby
This is a continuation of the Role and Permissions Question.
I had issues with Category, Post and Thread Policy. The forum stopped showing the "New Thread" button, and thread/post buttons. So, I did a fresh install (Wave and laravel-forum).
For sake of simplicity, I'm going to skip many steps and will not be adding coding at all. So, after installation,
- Used the forum as is. I was successfully been able to create a category and add a new thread. My observation: category/thread/post buttons were there like New reply, Quick reply and reply.
- Added BREAD to Forum Thread (TeamTeaTime\Forum\Models\Thread).
- Went back to the thread page, and refresh it. My observation: I lost most of the thread buttons and other controls.
- I removed the Bread, and the buttons appeared again.
Same happened with Forum Category BREAD: TeamTeaTime\Forum\Models\Category. I assume that something similar will happen with Forum Post: TeamTeaTime\Forum\Models\Post. All this was without adding code.
Any suggestion? Thank you
Hey there,
Indeed I was able to replicate the same behavior on my end :/ somehow the Voyager permissions and the Forum permissions are getting in each other's way.
An alternative approach is not to rely on the voyager permissions, but use the Forum permissions and policies. So something like this:
- Create a new Policy file with as you've done yesterday and in there define your custom permissions
- An example of this would be:
public function createThreads($user, Category $category): bool
{
if(auth()->user()->role->name == 'admin') {
return true;
} else {
return false;
}
}
The above would check if the user is admin and allow them to create new threads, you can adjust it to match your needs.
- You can get the base policies from the
./vendor/riari/laravel-forum/src/Policies/
directory and extend them as described in the Forumd docs
That way you don't have to use the BREAD functionality and you can have full control over the Forum policies based on your needs.
Let me know if this works for you!
Hey Bobby
Thank you for your response. I'm glad you could replicate the issue. I do appreciate your time and effort.
I think I finally found a solution... In order to be able to extend laravel-forum policies and manage role and permissions with Admin/Voyager, I had to add BREAD with an empty Model, and add the Model at my new policy files. Seems to work...
Hopefully I find no other issues... I need to move on!
Thank you Bobby
















Happy to hear that you've got it working! Good luck with your project!