fix: create member

This commit is contained in:
philipp lang 2021-04-10 03:08:34 +02:00
parent 0f6e5b5737
commit 58291d9d0e
3 changed files with 16 additions and 14 deletions

View File

@ -8,6 +8,7 @@ use App\Country;
use App\Member\Member; use App\Member\Member;
use App\Region; use App\Region;
use App\Nationality; use App\Nationality;
use App\Fee;
class InitializeMembers { class InitializeMembers {
@ -44,11 +45,12 @@ class InitializeMembers {
'email' => $member->email, 'email' => $member->email,
'email_parents' => $member->email_parents, 'email_parents' => $member->email_parents,
'nami_id' => $member->id, 'nami_id' => $member->id,
'gender_id' => Gender::firstOrFail('nami_id', $member->gender_id)->id, 'gender_id' => optional(Gender::firstWhere('nami_id', $member->gender_id))->id,
'confession_id' => optional(Confession::firstWhere('nami_id', $member->confession_id))->id, 'confession_id' => optional(Confession::firstWhere('nami_id', $member->confession_id))->id,
'region_id' => Region::firstOrFail('nami_id', $member->region_id)->id, 'region_id' => Region::where('nami_id', $member->region_id)->firstOrFail()->id,
'country_id' => Country::firstOrFail('nami_id', $member->country_id)->id, 'country_id' => Country::where('nami_id', '=', $member->country_id)->firstOrFail()->id,
'nationality_id' => Nationality::firstOrFail('nami_id', $member->nationality_id)->id, 'fee_id' => optional(Fee::firstWhere('nami_id', '=', $member->fee_id))->id,
'nationality_id' => Nationality::where('nami_id', $member->nationality_id)->firstOrFail()->id,
]); ]);
}); });
}); });

View File

@ -10,7 +10,7 @@ class Member extends Model
{ {
use Notifiable; use Notifiable;
public $fillable = ['firstname', 'lastname', 'nickname', 'other_country', 'birthday', 'joined_at', 'send_newspaper', 'address', 'further_address', 'zip', 'location', 'main_phone', 'mobile_phone', 'work_phone', 'fax', 'email', 'email_parents', 'nami_id', 'letter_address', 'country_id', 'way_id', 'nationality_id', 'subscription_id', 'region_id', 'gender_id', 'confession_id']; public $fillable = ['firstname', 'lastname', 'nickname', 'other_country', 'birthday', 'joined_at', 'send_newspaper', 'address', 'further_address', 'zip', 'location', 'main_phone', 'mobile_phone', 'work_phone', 'fax', 'email', 'email_parents', 'nami_id', 'letter_address', 'country_id', 'way_id', 'nationality_id', 'fee_id', 'region_id', 'gender_id', 'confession_id'];
public $dates = ['joined_at', 'birthday']; public $dates = ['joined_at', 'birthday'];
@ -79,8 +79,8 @@ class Member extends Model
return $this->hasMany(App\Membership::class); return $this->hasMany(App\Membership::class);
} }
public function subscription() public function fee()
{ {
return $this->belongsTo(App\Subscription::class); return $this->belongsTo(App\Fee::class);
} }
} }

View File

@ -14,14 +14,14 @@ class CreateMembersTable extends Migration
public function up() public function up()
{ {
Schema::create('members', function (Blueprint $table) { Schema::create('members', function (Blueprint $table) {
$table->increments('id'); $table->id();
$table->string('firstname'); $table->string('firstname');
$table->string('lastname'); $table->string('lastname');
$table->string('nickname')->nullable(); $table->string('nickname')->nullable();
$table->integer('gender_id')->unsigned()->nullable(); $table->foreignId('gender_id')->nullable()->constrained();
$table->integer('country_id')->unsigned(); $table->foreignId('country_id')->constrained();
$table->string('other_country')->nullable(); $table->string('other_country')->nullable();
$table->integer('confession_id')->unsigned()->nullable(); $table->foreignId('confession_id')->nullable()->constrained();
$table->date('birthday'); $table->date('birthday');
$table->date('joined_at'); $table->date('joined_at');
$table->boolean('send_newspaper'); $table->boolean('send_newspaper');
@ -29,7 +29,7 @@ class CreateMembersTable extends Migration
$table->string('further_address')->nullable(); $table->string('further_address')->nullable();
$table->string('zip'); $table->string('zip');
$table->string('location'); $table->string('location');
$table->string('region_id')->nullable(); $table->foreignId('region_id')->nullable()->constrained();
$table->string('main_phone')->nullable(); $table->string('main_phone')->nullable();
$table->string('mobile_phone')->nullable(); $table->string('mobile_phone')->nullable();
$table->string('work_phone')->nullable(); $table->string('work_phone')->nullable();
@ -37,8 +37,8 @@ class CreateMembersTable extends Migration
$table->string('email')->nullable(); $table->string('email')->nullable();
$table->string('email_parents')->nullable(); $table->string('email_parents')->nullable();
$table->integer('nami_id')->nullable(); $table->integer('nami_id')->nullable();
$table->integer('nationality_id')->unsigned(); $table->foreignId('nationality_id')->constrained();
$table->integer('subscription_id')->nullable(); $table->foreignId('fee_id')->constrained();
$table->timestamps(); $table->timestamps();
}); });