Closed sebastiaanluca closed 8 years ago
With $user->approve()
you mean $user->approve($resource)
?
And what about scopes? It works with scopes already.
@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 :)
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.
how to delete the rejected post ?
You can delete it directly using $post->delete()
or use withRejected
scope inside a query.
it give me error using $post->delete () NotFoundHttpException in Handler.php line 102: No query results for model [App\Post].
Which laravel version do you use?
i am using 5.2
Does the scope work for you?
yes its work but rejected and unapproved post do not delete give me error .
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.
Thank you (y)
Did the update fix your issue?
@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
@yoongkang0122 thanks your kind words, I am glad you like it. For issues regarding the book please head to this repo.
@sebastiaanluca methods on single instace have been added on v1.0.6.
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.