MKhalidwebdesignguy.me·Jan 14, 2024Laravel Models: Your Gateway to Efficient Data ManagementHey there! Are you diving into the fascinating world of Laravel, or maybe just looking to brush up on some concepts? Either way, you’re in the right place. Today, we’re going to chat about Laravel models – those magical bits of code that make working...DiscussLaravel
MKhalidwebdesignguy.me·Jan 11, 2024Mastering Eloquent ORM in Laravel: Advanced Tips and TechniquesEloquent ORM in Laravel simplifies the interaction with databases, offering an expressive and fluent way to handle database operations. In this post, we’ll explore advanced techniques to make the most of Eloquent ORM, enhancing the efficiency and sca...Discuss·1 likePHP
David Nguyeneplus.dev·Oct 11, 2023Laravel Eloquent HasManyThrough relationships with unlimited levelsThis extended version of HasManyThrough allows relationships with unlimited intermediate models.It supports many-to-many and polymorphicrelationships and all their possible combinations. It also supports some third-party packages. Supports Laravel 5....Discuss·58 readsLaraveleloquent
David Nguyeneplus.dev·Oct 11, 2023Laravel Eloquent TipsThis is a short list of the amazing hidden Laravel eloquent 30 tips that make the code go on smoothly. This is a short list of the amazing hidden Laravel eloquent 30 tips that make the code go on smoothly. 1 – Invisible Database Columns The invisible...Discuss·32 readsLaraveleloquent
Ghanshyam DigitalforGhanshyam Digitalblog.ghanshyamdigital.com·Jan 30, 2023Building a Self-Referencing Model in Laravel: A Step-by-Step Guide1. Introduction Self-referencing models, also known as recursive relationships, are a powerful tool in Laravel's Eloquent ORM (Object-Relational Mapping) system. They allow a model to have a relationship with itself, which can be useful for data stru...Discuss·6 likes·3.8K readsLaravel
Jasper Teyjaspertey.com·Jan 10, 2023Another way to prepend table names to columns in Eloquent queriesWhen writing complex queries in Eloquent, you will more than likely encounter scenarios forcing you to prefix column references with the table name to handle SQL ambiguity, especially when joins are involved. Consider the following ways you might've ...Discuss·105 readsLaravel
Yunus Shaikhyunus.in·Jan 1, 2023How to get a single record from hasMany Relation in Laravel in the most efficient way.$users = User::query()->addSelect([ 'last_ordered_at' => Order::select("created_at") ->whereColumn('user_id', 'users.id') ->latest() ->take(1), ])->orderBy('name')->paginate(); Cons...Discuss·2 likes·108 readsLaravel
Tjtajid.hashnode.dev·Mar 19, 2022Nullable Uniques on Eloquent ModelWe could setup a composite unique index for two more fields through $table->unique(['company_id', 'email']), to make sure that each email address is used only by user in a company utilizing database unique constraints. The problem arise when we need ...Discuss·76 readsLaravel
Olguncodewitholgun.com·Feb 20, 2022Laravel Eloquent Tutorial - Get only the fields (aka columns) we need from relation.Laravel is a great framework to work with, and I use it every day for my 9-5 job. One of the greatest power of Laravel is, it has an ORM (Object Relational Mapping) as default called Eloquent. I am not going to talk about what is Eloquent ORM, but I ...Discuss·12 likes·828 readsLaravel
Hasan MNhasanmn.dev·Oct 16, 2021Automatically Update `created_by` and `updated_by` in Laravel Using Bootable TraitsIf you use timestamps feature in Laravel, then you got the free feature of auto-update on created_at and update_at columns when the model is created or updated. Now, what if you want the same thing for you own customs created_by and updated_by column...Discuss·294 readsLaravel