hootlex / laravel-moderation

A simple Content Moderation System for Laravel 5.* that allows you to Approve or Reject resources like posts, comments, users, etc.
MIT License
526 stars 68 forks source link

Actions on a single instance #6

Closed sebastiaanluca closed 8 years ago

sebastiaanluca commented 8 years ago

Perhaps an idea to allow $user->approve(), $user->reject, $user->postpone(), et cetera? :)

Oh, and scopes! That way it can be combined with other query limitations like wheres and whatnot.

hootlex commented 8 years ago

With $user->approve() you mean $user->approve($resource)?

And what about scopes? It works with scopes already.

sebastiaanluca commented 8 years ago

@hootlex I mean $user is the moderated resource and I want to approve, reject, postpone it. E.g. $post->reject() instead of doing Post::reject($postId). So on the instance itself, should've made that clear in the first post.

Would just be a nice feature, nothing more :)

hootlex commented 8 years ago

I like this feature too. Before I published this package I tried to implement these methods but there were collisions with approve, reject, ... function between the trait and the scope, since both had the same names. So, I had 2 options: 1. Rename functions on the trait (ex. doApprove) 2. Remove the functions.

As you can see I chose the second option since I didnt like to have both approve and doApprove functions. :)

If you believe that it will be useful to call $user->doApprove(), or if you have an idea on how it can be achieved to share the same method names let me know.

furqan99 commented 8 years ago

how to delete the rejected post ?

hootlex commented 8 years ago

You can delete it directly using $post->delete() or use withRejected scope inside a query.

furqan99 commented 8 years ago

it give me error using $post->delete () NotFoundHttpException in Handler.php line 102: No query results for model [App\Post].

hootlex commented 8 years ago

Which laravel version do you use?

furqan99 commented 8 years ago

i am using 5.2

hootlex commented 8 years ago

Does the scope work for you?

furqan99 commented 8 years ago

yes its work but rejected and unapproved post do not delete give me error .

hootlex commented 8 years ago

I tested it myself and I am able to delete rejected/pending posts running

$post = Post::withRejected()->where('id', $id)->first();
$post->delete();

Please update the package to the latest version.

furqan99 commented 8 years ago

Thank you (y)

hootlex commented 8 years ago

Did the update fix your issue?

yoongkang0122 commented 8 years ago

@hootlex you are great man!!! i love your book. I hope you can publish more book. Then I can continue to learn new thing with you

hootlex commented 8 years ago

@yoongkang0122 thanks your kind words, I am glad you like it. For issues regarding the book please head to this repo.

hootlex commented 8 years ago

@sebastiaanluca methods on single instace have been added on v1.0.6.