Home > other >  Laravel mass update enum column to different value through Tinker
Laravel mass update enum column to different value through Tinker

Time:11-03

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 Illuminate\Database\Eloquent\Model::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?

CodePudding user response:

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'));

CodePudding user response:

try this version


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