Laravel Eloquent: upsert for Bulk Operations
January 16, 2026
•
1 min read
•
17 views
Table of Contents
Efficient bulk operations:
Basic Upsert
User::upsert([
['email' => 'john@example.com', 'name' => 'John'],
['email' => 'jane@example.com', 'name' => 'Jane'],
], ['email'], ['name']);
UpdateOrCreate
$user = User::updateOrCreate(
['email' => 'john@example.com'],
['name' => 'John Doe']
);
FirstOrCreate
$user = User::firstOrCreate(
['email' => 'john@example.com'],
['name' => 'John']
);
Insert Ignore
User::insertOrIgnore([
['email' => 'john@example.com'],
]);
Related Posts
Laravel Sanctum API Authentication Complete Guide
Build secure API authentication with Laravel Sanctum for SPAs and mobile apps.
Laravel Rate Limiting: Protect Your Application
Implement rate limiting to protect your Laravel application from abuse.
Laravel Blade Components: Build Reusable UI
Create powerful reusable components with Laravel Blade.
Comments (0)
No comments yet. Be the first to comment!