How can I create a migration to add a new column full_name using first_name and last_name columns?
How can I create a migration to add a new column full_name using first_name and last_name columns? I’m trying something like this but without results:
public function up()
{
Schema::table('users', function (Blueprint $table) {
// ALTER TABLE v_column ADD full_name char(41) GENERATED ALWAYS AS (concat(firstname,' ',lastname)) VIRTUAL NOT NULL;
$table->text('full_name')->virtualAs(DB::concat('last_name', 'first_name'));
});
}
No any search results
You already invited:
1 Answers
Dmitry
Upvotes from:
Is that a real function, DB::concat('last_name', 'first_name')? Not sure I've ever come across it. In any event, I would think you'd need to use a string there instead.
(just as you have in the commented plain SQL query)