89 lines
3.6 KiB
PHP
89 lines
3.6 KiB
PHP
<?php
|
|
|
|
use Phinx\Migration\AbstractMigration;
|
|
|
|
final class CreateNotificationsettingTable extends AbstractMigration
|
|
{
|
|
public function change(): void
|
|
{
|
|
$this->table('notificationsetting', ['id' => 'idnotificationsetting'])
|
|
->addColumn('notificationtype', 'string', [
|
|
'limit' => 30,
|
|
'null' => false,
|
|
'comment' => 'lesson / order / certificate',
|
|
])
|
|
->addColumn('daysbefore', 'integer', [
|
|
'null' => false,
|
|
'default' => 0,
|
|
'comment' => 'Giorni di anticipo; 0 = il giorno stesso',
|
|
])
|
|
->addColumn('sendhour', 'string', [
|
|
'limit' => 5,
|
|
'null' => false,
|
|
'default' => '08:00',
|
|
'comment' => 'Ora di invio del cron (HH:MM)',
|
|
])
|
|
->addColumn('active', 'char', [
|
|
'limit' => 1,
|
|
'null' => false,
|
|
'default' => 'Y',
|
|
])
|
|
->addColumn('title', 'string', [
|
|
'limit' => 150,
|
|
'null' => false,
|
|
])
|
|
->addColumn('body', 'text', [
|
|
'null' => false,
|
|
])
|
|
->addIndex(
|
|
['notificationtype', 'daysbefore'],
|
|
['unique' => true, 'name' => 'uq_notificationsetting_type']
|
|
)
|
|
->insert([
|
|
[
|
|
'notificationtype' => 'lesson',
|
|
'daysbefore' => 0,
|
|
'sendhour' => '08:00',
|
|
'active' => 'Y',
|
|
'title' => 'La tua lezione di oggi',
|
|
'body' => 'Ciao {first_name}, oggi hai {servicename} alle {time}. Ti aspettiamo!',
|
|
],
|
|
[
|
|
'notificationtype' => 'order',
|
|
'daysbefore' => 5,
|
|
'sendhour' => '08:00',
|
|
'active' => 'Y',
|
|
'title' => 'Il tuo abbonamento sta per scadere',
|
|
'body' => 'Ciao {first_name}, il tuo abbonamento scade il {expiredate}. '
|
|
. 'Ricordati di prenotare le lezioni rimaste.',
|
|
],
|
|
[
|
|
'notificationtype' => 'order',
|
|
'daysbefore' => 0,
|
|
'sendhour' => '08:00',
|
|
'active' => 'Y',
|
|
'title' => 'Il tuo abbonamento scade oggi',
|
|
'body' => 'Ciao {first_name}, oggi e\' l\'ultimo giorno del tuo abbonamento.',
|
|
],
|
|
[
|
|
'notificationtype' => 'certificate',
|
|
'daysbefore' => 7,
|
|
'sendhour' => '08:00',
|
|
'active' => 'Y',
|
|
'title' => 'Certificato medico in scadenza',
|
|
'body' => 'Ciao {first_name}, il tuo certificato medico scade il {expiredate}.',
|
|
],
|
|
[
|
|
'notificationtype' => 'certificate',
|
|
'daysbefore' => 5,
|
|
'sendhour' => '08:00',
|
|
'active' => 'Y',
|
|
'title' => 'Certificato medico in scadenza',
|
|
'body' => 'Ciao {first_name}, mancano pochi giorni: il tuo certificato medico '
|
|
. 'scade il {expiredate}.',
|
|
],
|
|
])
|
|
->create();
|
|
}
|
|
}
|