I want to update my database with one of the table columns called "confirmed" as value 1 in the database table together by just running a single query bulk update, At that time I was facing Using $this when not in object context error while executing update query. I solved this error just by adding the query() method before executing the query in the laravel application.
Error
I am trying to update the whole table confirmed column at once by running the below laravel eloquent model query, by running this query I was facing an error, Using $this when not in object context. so how do bulk update columns in the database table using the laravel eloquent model? checkout out a given solution.
Model::update(['confirmed' => 1]);
Solution
By adding a query() before applying the update confirmed column in the database using the laravel model eloquent, I fixed this error. so you just need to add the query() method before applying direct any method in the laravel eloquent model.
Model::query()->update(['confirmed' => 1]);
We always thanks to you for reading our blogs.
Dharmesh Chauhan
(Swapinfoway Founder)Hello Sir, We are brothers origin from Gujarat India, Fullstack developers working together since 2016. We have lots of skills in web development in different technologies here I mention PHP, Laravel, Javascript, Vuejs, Ajax, API, Payment Gateway Integration, Database, HTML5, CSS3, and Server Administration. So you need our service Please Contact Us
Haresh Chauhan
(Co-Founder)We Are Also Recommending You :
- Laravel 9 Dropzone Multiple File Upload Example
- Error : The MAC is invalid Question's And Solutions [Solved]
- Pinelabs Payment Gateway Integration Tutorial In Laravel
- PhonePe Payment Gateway Integration in Laravel 12 (Step-by-Step Guide 2026)
- Error : Using $this when not in object context update column laravel
- [Fixed] Binary Does Not Exist Laravel
- Web Push Notification Send Using Firebase Cloud Messaging In Laravel Tutorial Include Demo Example
- Unique violation: 7 ERROR: duplicate key value violates unique constraint "users_pkey" DETAIL: Key (id)=(1) already exists.
- Cashfree Payment Gateway Integration In Laravel
- How To Clone Laravel