Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Actions on a single instance #6

Closed
sebastiaanluca opened this issue Mar 4, 2016 · 16 comments
Closed

Actions on a single instance #6

sebastiaanluca opened this issue Mar 4, 2016 · 16 comments

Comments

@sebastiaanluca
Copy link

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
Copy link
Owner

hootlex commented Mar 4, 2016

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

And what about scopes? It works with scopes already.

@sebastiaanluca
Copy link
Author

@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
Copy link
Owner

hootlex commented Mar 5, 2016

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
Copy link

furqan99 commented Apr 1, 2016

how to delete the rejected post ?

@hootlex
Copy link
Owner

hootlex commented Apr 1, 2016

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

@furqan99
Copy link

furqan99 commented Apr 1, 2016

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

@hootlex
Copy link
Owner

hootlex commented Apr 1, 2016

Which laravel version do you use?

@furqan99
Copy link

furqan99 commented Apr 1, 2016

i am using 5.2

@hootlex
Copy link
Owner

hootlex commented Apr 2, 2016

Does the scope work for you?

@furqan99
Copy link

furqan99 commented Apr 2, 2016

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

@hootlex
Copy link
Owner

hootlex commented Apr 2, 2016

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
Copy link

furqan99 commented Apr 3, 2016

Thank you (y)

@hootlex
Copy link
Owner

hootlex commented Apr 3, 2016

Did the update fix your issue?

@yoongkang0122
Copy link

yoongkang0122 commented May 4, 2016

@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
Copy link
Owner

hootlex commented May 4, 2016

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

@hootlex hootlex closed this as completed May 4, 2016
@hootlex
Copy link
Owner

hootlex commented Jun 22, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants