skip to Main Content

I’m trying to do a mass-update of an enum column’s value in my Laravel 9 project through tinker, my model is called Domain and I have an enum column called status with different values.

I’d like to select all entries where status is expired and set them to a different value.

I’ve tried running this in Tinker but it throws an error:

PHP Deprecated: Non-static method IlluminateDatabaseEloquentModel::update() should not be called statically in /Users/ryanholton/Sites/fudge-apieval()’d code on line 1

Domain::where('status', 'expired')->update(['status' => 'pending']);

What am I missing?

2

Answers


  1. You can use Eloquent this way

    Domain::query()->where('status', 'expired')->update(['status' => 'pending']);
    

    Or You can use DB query this way

    DB::table('domains')->where('status', 'expired')->update(array('status' => 'pending'));
    
    Login or Signup to reply.
  2. try this version

    
    Domain::query()->where('status', 'expired')->update(['status' => 'pending']);
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search