Menu
Newbedev LogoNEWBEDEV Python Javascript Linux Cheat sheet
Newbedev LogoNEWBEDEV
  • Python 1
  • Javascript
  • Linux
  • Cheat sheet
  • Contact

Laravel 5: Querying a many to many relationship without "pivot" in the result

Use the pluck() method:

$user->favouriteBooks()->pluck('book_id');

I recommend putting pivot in the hidden array like in user.php:

protected $hidden = ['pivot'];

which would remove pivot from all json's returned.

Tags:

Laravel

Laravel 5

Related

comparing two fields that may be null Redis keys are not expiring - Laravel, Predis Weighted random sample without replacement in python ALTER TABLE DROP COLUMN failed because one or more objects access this column How to turn off telemetry for SQL 2016 Android View outline - using a custom Path Is it really so difficult to draw smooth lines in Unity? How to calculate F1 Macro in Keras? Visual studio team services deploymen/buildt certificate error Wordpress JSON API returns normal site page in html. How do I get it to give me JSON like it's supposed to How to run Tensorboard and jupyter concurrently with docker? React Native Picker Styling - ANDROID

Recent Posts

Pandas how to find column contains a certain value Recommended way to install multiple Python versions on Ubuntu 20.04 Build super fast web scraper with Python x100 than BeautifulSoup How to convert a SQL query result to a Pandas DataFrame in Python How to write a Pandas DataFrame to a .csv file in Python
© 2021 newbedevPrivacy Policy