Php

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'));
});
}
You already invited:

Dmitry

Upvotes from:

Regarding the localization question, it's really up to you... the primary advantage of using the localization files is that it keeps all of the translations in one place, which in turn makes them easier to manage.
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)

If you wanna answer this question please Login or Register