Column not found: 1054 Unknown column '0' in 'field list' - Laravel - I don't have a 0 column anywhere in my code

The error is due to ->update(['locked', 1]); which should be ->update(['locked' => 1]);

the update function uses an array as "column" => "value", your syntax error causes Laravel to think [ 0 => 'locked', 1 => 1], so it translates to this SQL SET 0 = 'locked', 1 = 1...


As I mentioned in the comment section, change your function to this:

public function scopeLock($query)
{
    return $query->where('locked', 0)->update(['locked' => 1]);
}

Note the changes in the update method.