Laravel Community Tools by Tighten

Tag "eloquent" tricks

24 tricks
You can unguard all your Models instead of setting the protected guarded variable to an empty array in each App\Models\YourModel class using Model::unguard() in the boot method of AppServiceProvider class.
berto309 5 years ago 24174
Laravel package to let you manage de-normalized tables with simple configurations. Just add array based config in your models and it will automatically sync your denormalized tables. https://github.com/tkeer/flattable
tkeer 5 years ago 15164
Check if the collection exists or not.
debjit 5 years ago 17962
case: user has many posts and post has many comments. we need user's posts with comments:
sanjok1988 5 years ago 13302
Here a user has a location with many to many positions. This query finds users having position id 4 and location id 6. the tables are users, profile, locations. and profile has location_id.
sanjok1988 5 years ago 12727
wrong and right way to write eloquent
sanjok1988 5 years ago 8387
Here posts and categories have many to many relationships. the tricks are to fetch posts having a particular category attribute with categories details.
sanjok1988 5 years ago 11537
if you want to use ORM eloquent to get a query with the third table and select only particular attributes then here is the trick. Here users can have multiple positions in a company and each user has their own user profile. *note that user_id must be here to fetch data with a specific column. without foreign key eloquent cannot map relational table
sanjok1988 5 years ago 18341
Laravel is a web application framework with expressive, elegant syntax.The PHP Framework for Web Artisans,freeing you to create without sweating the small things. CRUD Operation With Server Side.
pakainfo-c... 5 years ago 13031