Team-Tea-Time/laravel-forum

viewTrashedPosts

DevHoracioRodriguez opened this issue · 2 comments

Hello Riari

How I can make viewTrashedPosts and viewTrashedThreads to validate user? The idea is to show soft deleted thread/posts to authors and authorized roles.

For example:

public function viewTrashedThreads($user, Post $post): bool
{
	return $user->getKey() === $post->author_id || $user->role->name = "admin" || $user->role->name = "moderator";
}

public function viewTrashedPosts($user, Thread $thread): bool
{
	return $user->getKey() === $thread->author_id || $user->role->name = "admin" || $user->role->name = "moderator";
}
  • Anyways, I haven't been able to make it work at Forum level (ForumPolicy::viewTrashedPosts).

Any suggestions?

Thank you in advance.

If in anything helps, this is connected with prior efforts found in this link: #324
Also, #323

Riari commented
$user->role->name = "admin" || $user->role->name = "moderator"

You're doing assignments here instead of comparisons. Change them to == and see if that works.

Thank you Riari for the observation.

I think I'm not going to use the soft delete. I figure that most of my users don't know what a soft delete is. So, on forum.general I changed the soft_deletes and display_trashed_posts to false. In this way I will avoid any confusion. So, far, it's working as expected.

Thank you for your help!