I have the table evaluations that have the columns nota1, nota2, nota3, nota4 created in the database and wanted to create a media column that already calculated the media automatically, how to create this column calculate using migrate from laravel?
public function up()
{
Schema::create('avaliacoes', function(Blueprint $table)
{
$table->increments('id');
$table->integer('nota1')->default(0);
$table->integer('nota2')->default(0);
$table->integer('nota3')->default(0);
$table->integer('nota4')->default(0);
//criar columa media aqui = (nota1+nota2+nota3+nota4) / 4
});
}
nota1 | nota2 | nota3 | nota4 | // criar coluna media
2 | 3 | 4 | 5 | // Media aqui