Assign raw value to Lucid model attributes

Assume this:

const post = new Post()
post.published_at = 'NOW()'
post.save()

Using Eloquent we are able to do so:

$post->published_at = DB::raw('NOW()');

Is there a similar way for Lucid or something else?
I’m not going to use query builder or mass update function.

2 Likes

I really should guess it. This is working.

post.published_at = Database.raw('NOW()')

Such a useful thing isn’t mentioned in official docs.

3 Likes