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
Remove pivot attribute with toArray/toJson method #745
Comments
Add it to your "hidden" array. |
You're right! |
For future fellow Laravel 4.1.x journeymen, please refer to the Docs under Eloquent / Converting to Arrays or JSON on how to use the <?php
class User extends Eloquent
{
protected $hidden = array('pivot');
} |
But how do you hide a specific field within pivot table, like <?php
class User extends Eloquent
{
protected $hidden = array('pivot.created_at');
} |
@monove Following trick worked for me... Add following method to your Model.
|
@vatps yes!!! man thank you!!! |
great!! thank you :) |
You can also use that i.e.
|
Mark, thank you guys |
@taylorotwell Any way to remove using query builder? ie. I need pivot key in a specific endpoint. |
Adding |
you can temporarily hide attributes using |
Please remove the pivot attribute of a "jsonified" model. Since it makes an api "fatter" then needed.
The text was updated successfully, but these errors were encountered: