Browse Source

Add mail location field for dynamic mail storage

master
Vincent Canfield 3 years ago
parent
commit
71b731e55c

+ 1
- 0
app/Services/Registrar.php View File

@@ -48,6 +48,7 @@ class Registrar implements RegistrarContract {
'email' => strtolower($data['username'] . '@' . $data['domain']),
'password' => bcrypt($data['password']),
'registered_ip' => $_SERVER['REMOTE_ADDR'],
'mail_location' => strtolower(sprintf('maildir:/var/mail/vhosts/%s/%s/',$data['domain'],$data['username']))
]);
}


+ 1
- 1
app/User.php View File

@@ -20,7 +20,7 @@ class User extends Model implements AuthenticatableContract {
*
* @var array
*/
protected $fillable = ['email', 'password','registered_ip','created_at','updated_at','disabled'];
protected $fillable = ['email', 'password','registered_ip','created_at','updated_at','disabled','mail_location'];

/**
* The attributes excluded from the model's JSON form.

+ 44
- 0
database/migrations/2016_10_15_071932_add_mail_location_column.php View File

@@ -0,0 +1,44 @@
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

use App\User;

class AddMailLocationColumn extends Migration {

/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users',function(Blueprint $table){
$table->string('mail_location')->nullable();
});

$users = User::all();

foreach($users as $user) {
$user_split = explode('@',$user->email);
$user->mail_location = sprintf('maildir:/var/mail/vhosts/%s/%s/',$user_split[1],$user_split[0]);
$user->save();
}

Schema::table('users',function(Blueprint $table){
$table->string('mail_location')->nullable(false)->change();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}

}

Loading…
Cancel
Save