Perhaps this was not possible a few years ago but in recent versions of Laravel you can definitely do:
User::where('age', '<', 18)->update(['under_18' => 1]);
Worth noting that you need the where method before calling update
.
More Related Contents:
- Laravel Check If Related Model Exists
- How to alias a table in Laravel Eloquent queries (or using Query Builder)?
- Laravel Eloquent: How to order results of related models?
- Laravel 4: how to “order by” using Eloquent ORM [duplicate]
- How to set a default attribute value for a Laravel / Eloquent model?
- Laravel Eloquent – Attach vs Sync
- How to create a subquery using Laravel Eloquent?
- Update without touching timestamps (Laravel)
- How can I query raw via Eloquent?
- Find or Create with Eloquent
- Laravel Many to many self referencing table only works one way
- How to Create Multiple Where Clause Query Using Laravel Eloquent?
- Get the Last Inserted Id Using Laravel Eloquent
- How to insert multiple rows from a single query using eloquent/fluent
- Laravel orderBy on a relationship
- Laravel – Eloquent or Fluent random row
- Creating and Update Laravel Eloquent
- How to sort a Laravel query builder result by multiple columns?
- MVC (Laravel) where to add logic
- What is the syntax for sorting an Eloquent collection by multiple columns?
- Laravel named route for resource controller
- How to alias the name of a column in Eloquent
- Laravel $q->where() between dates
- file_put_contents(meta/services.json): failed to open stream: Permission denied
- PHP Composer update “cannot allocate memory” error (using Laravel 4)
- laravel collection to array
- Natural ORDER in Laravel Eloquent ORM
- Using namespaces in Laravel 4
- Laravel extend Form class
- Can’t make Laravel 4 to work on localhost