diff --git a/backend/app/Http/Controllers/Api/FathersController.php b/backend/app/Http/Controllers/Api/FathersController.php index 07f6c17a..d714451a 100644 --- a/backend/app/Http/Controllers/Api/FathersController.php +++ b/backend/app/Http/Controllers/Api/FathersController.php @@ -59,7 +59,7 @@ class FathersController extends Controller { 'email' => $r->email, 'token' => $token, 'ttl' => date('Y-m-d H:i:s', strtotime("8 hour")), - + 'relation_limit' => $result->relation_limit, ]; try { @@ -169,7 +169,7 @@ class FathersController extends Controller { return ['status_code' => 422, 'error_messages' => $validate->errors()]; } - if ($get = EmailActivation::select('email', 'ttl')->where('token', $r->token)->first()) { + if ($get = EmailActivation::select('email', 'ttl', 'relation_limit')->where('token', $r->token)->first()) { if (time() > strtotime($get->ttl)) { // 有効期限が切れている場合 return['status_code' => 401, 'error_messages' => ['仮登録の有効期限が切れました。改めて管理者にお問い合わせいただき、再登録を行ってください。']]; @@ -196,6 +196,7 @@ class FathersController extends Controller { 'image' => !is_null($r->image) ? '/files/'.$filename : '/assets/default/avatar.jpg', 'profile' => $r->profile, 'tel' => $r->tel, + 'relation_limit' => $get->relation_limit, ]; // DBに入ります。 diff --git a/backend/app/Models/EmailActivation.php b/backend/app/Models/EmailActivation.php index 90839929..cb9ec025 100644 --- a/backend/app/Models/EmailActivation.php +++ b/backend/app/Models/EmailActivation.php @@ -8,6 +8,6 @@ use Illuminate\Database\Eloquent\Model; class EmailActivation extends Model { use HasFactory; - protected $fillable = ['type', 'father_id', 'email', 'token', 'ttl']; + protected $fillable = ['type', 'father_id', 'email', 'token', 'ttl', 'relation_limit']; protected $attributes = ['type' => 0]; } diff --git a/backend/database/factories/EmailActivationFactory.php b/backend/database/factories/EmailActivationFactory.php index 2809fe76..8cc128b0 100644 --- a/backend/database/factories/EmailActivationFactory.php +++ b/backend/database/factories/EmailActivationFactory.php @@ -27,6 +27,7 @@ class EmailActivationFactory extends Factory 'email' => $this->faker->email, 'token' => $this->faker->creditCardNumber, 'ttl' => $this->faker->dateTime, + 'relation_limit' => rand(1,10), 'created_at' => $this->faker->dateTime, 'updated_at' => $this->faker->dateTime, ]; diff --git a/backend/database/migrations/2021_08_13_020003_create_email_activations_table.php b/backend/database/migrations/2021_08_13_020003_create_email_activations_table.php index 54b04c74..fa7a477c 100644 --- a/backend/database/migrations/2021_08_13_020003_create_email_activations_table.php +++ b/backend/database/migrations/2021_08_13_020003_create_email_activations_table.php @@ -20,6 +20,7 @@ class CreateEmailActivationsTable extends Migration $table->string('email', 255)->unique(); $table->string('token', 64)->unique(); $table->dateTime('ttl'); + $table->unsignedInteger('relation_limit'); $table->timestamps(); }); }