From 24c0a1bbb4005748036b5384920a4d4d2a38dc6a Mon Sep 17 00:00:00 2001 From: dragon1211 Date: Fri, 24 Dec 2021 10:01:44 -0800 Subject: [PATCH 1/2] add invite with father info --- backend/public/js/app.js | 5 +++-- backend/resources/js/child/auth/register/temporary.jsx | 1 + backend/resources/js/parent/child/add.jsx | 4 ++-- backend/resources/views/c_account/auth.blade.php | 5 +++++ backend/routes/web.php | 2 +- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/backend/public/js/app.js b/backend/public/js/app.js index ef236691..0fe04f74 100644 --- a/backend/public/js/app.js +++ b/backend/public/js/app.js @@ -40154,6 +40154,7 @@ var ChildSignUpTemporary = function ChildSignUpTemporary() { }); var formdata = new FormData(); formdata.append('tel', tel); + formdata.append('father_id', document.getElementById('father_token').value); setSubmit(true); axios__WEBPACK_IMPORTED_MODULE_1___default().post('/api/children/registerTemporary', formdata).then(function (response) { setSubmit(false); @@ -46399,13 +46400,13 @@ var ChildAdd = function ChildAdd() { }; var copyInviteURL = function copyInviteURL() { - var inviteText = "https://kikikan.xyz/c-account/register-temporary"; + var inviteText = "https://kikikan.xyz/c-account/register-temporary?father_id=".concat(father_id); clipboard_copy__WEBPACK_IMPORTED_MODULE_4___default()(inviteText); setSuccess('招待用URLをコピーしました。'); }; var copyLineText = function copyLineText() { - var lineText = "「KIKI」の招待が届いています。%0Aまずは以下より仮登録を行ってください。%0Ahttps%3A%2F%2Fkikikan.xyz%2Fc-account%2Fregister-temporary%0A%0A▼公式サイトはこちら%0Ahttps%3A%2F%2Fkikikan.xyz"; + var lineText = "\u300CKIKI\u300D\u306E\u62DB\u5F85\u304C\u5C4A\u3044\u3066\u3044\u307E\u3059\u3002%0A\u307E\u305A\u306F\u4EE5\u4E0B\u3088\u308A\u4EEE\u767B\u9332\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002%0Ahttps%3A%2F%2Fkikikan.xyz%2Fc-account%2Fregister-temporary%3Ffather_id%3D".concat(father_id, "%0A%0A\u25BC\u516C\u5F0F\u30B5\u30A4\u30C8\u306F\u3053\u3061\u3089%0Ahttps%3A%2F%2Fkikikan.xyz"); clipboard_copy__WEBPACK_IMPORTED_MODULE_4___default()(lineText); setSuccess('招待用URLをLINEで追信しました。'); window.open('http://line.me/R/msg/text/?' + lineText); diff --git a/backend/resources/js/child/auth/register/temporary.jsx b/backend/resources/js/child/auth/register/temporary.jsx index dab8c389..a290dd44 100644 --- a/backend/resources/js/child/auth/register/temporary.jsx +++ b/backend/resources/js/child/auth/register/temporary.jsx @@ -18,6 +18,7 @@ const ChildSignUpTemporary = () => { const formdata = new FormData(); formdata.append('tel', tel); + formdata.append('father_id', document.getElementById('father_token').value); setSubmit(true); axios.post('/api/children/registerTemporary', formdata) .then(response => { diff --git a/backend/resources/js/parent/child/add.jsx b/backend/resources/js/parent/child/add.jsx index a99df147..7595cb8b 100644 --- a/backend/resources/js/parent/child/add.jsx +++ b/backend/resources/js/parent/child/add.jsx @@ -39,13 +39,13 @@ const ChildAdd = () => { } const copyInviteURL = () => { - const inviteText = "https://kikikan.xyz/c-account/register-temporary"; + const inviteText = `https://kikikan.xyz/c-account/register-temporary?father_id=${father_id}`; copy(inviteText); setSuccess('招待用URLをコピーしました。'); } const copyLineText = () => { - const lineText = "「KIKI」の招待が届いています。%0Aまずは以下より仮登録を行ってください。%0Ahttps%3A%2F%2Fkikikan.xyz%2Fc-account%2Fregister-temporary%0A%0A▼公式サイトはこちら%0Ahttps%3A%2F%2Fkikikan.xyz"; + const lineText = `「KIKI」の招待が届いています。%0Aまずは以下より仮登録を行ってください。%0Ahttps%3A%2F%2Fkikikan.xyz%2Fc-account%2Fregister-temporary%3Ffather_id%3D${father_id}%0A%0A▼公式サイトはこちら%0Ahttps%3A%2F%2Fkikikan.xyz`; copy(lineText); setSuccess('招待用URLをLINEで追信しました。'); window.open('http://line.me/R/msg/text/?'+lineText); diff --git a/backend/resources/views/c_account/auth.blade.php b/backend/resources/views/c_account/auth.blade.php index da88c1a3..017e1c7d 100644 --- a/backend/resources/views/c_account/auth.blade.php +++ b/backend/resources/views/c_account/auth.blade.php @@ -4,4 +4,9 @@ @section('content')
+ +@if (Request::is('c-account/register-temporary')) + +@endif + @endsection \ No newline at end of file diff --git a/backend/routes/web.php b/backend/routes/web.php index bef56339..ca5cb070 100644 --- a/backend/routes/web.php +++ b/backend/routes/web.php @@ -70,7 +70,7 @@ Route::get('/unknown-error ', function () { return vie // ---------------------------------------- Child Account ------------------------------------------- // Route::group(['prefix' => 'c-account'], function () { - Route::get('/register-temporary', function () { return view('c_account.auth'); }); + Route::get('/register-temporary', function(Request $r){ return view('c_account.auth', ['father_id'=>$r->father_id]);}); Route::get('/login', '\App\Http\Controllers\Api\ChildrenController@checkLogin')->name('childrenlogin'); Route::get('/logout', '\App\Http\Controllers\Api\ChildrenController@logout'); Route::get('/withdrawal/complete', function () { return view('c_account.auth'); }); From 60b67762e3faa5aed1fc3ad2de35f183bea3b56d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=86=E3=82=AF=E3=83=8B=E3=82=AB=E3=83=AB=E8=AB=8F?= =?UTF-8?q?=E8=A8=AA=E5=AD=90?= Date: Fri, 24 Dec 2021 14:40:31 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=E3=80=8C=E8=A6=AA=E3=81=8C=E5=AD=90?= =?UTF-8?q?=E3=81=AB=E6=8B=9B=E5=BE=85URL=E3=82=92=E9=80=81=E3=81=A3?= =?UTF-8?q?=E3=81=9F=E5=A0=B4=E5=90=88=E3=80=81=E5=AD=90=E3=81=AE=E6=9C=AC?= =?UTF-8?q?=E7=99=BB=E9=8C=B2=E5=AE=8C=E4=BA=86=E6=99=82=E3=81=AB=E6=8B=9B?= =?UTF-8?q?=E5=BE=85=E3=81=97=E3=81=9F=E8=A6=AA=E3=81=A8=E6=8B=9B=E5=BE=85?= =?UTF-8?q?=E3=81=95=E3=82=8C=E3=81=9F=E5=AD=90=E3=81=8C=E8=87=AA=E5=8B=95?= =?UTF-8?q?=E3=81=A7=E3=83=AA=E3=83=AC=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3?= =?UTF-8?q?=E3=80=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Http/Controllers/Api/ChildrenController.php | 16 ++++++++++++++++ backend/app/Models/TelActivation.php | 2 +- .../database/factories/TelActivationFactory.php | 3 +++ ...08_13_050204_create_tel_activations_table.php | 2 ++ backend/routes/web.php | 2 +- 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/backend/app/Http/Controllers/Api/ChildrenController.php b/backend/app/Http/Controllers/Api/ChildrenController.php index 18bc5c69..df667563 100644 --- a/backend/app/Http/Controllers/Api/ChildrenController.php +++ b/backend/app/Http/Controllers/Api/ChildrenController.php @@ -64,6 +64,10 @@ class ChildrenController extends Controller { 'ttl' => date('Y-m-d H:i:s', strtotime("8 hour")), ]; + if (isset($r->father_id) && $r->father_id > 0) { + $create['father_id'] = $r->father_id; + } + try { // DBに入ります。 DB::beginTransaction(); @@ -176,6 +180,18 @@ class ChildrenController extends Controller { $child->fill($insert); $child->push(); + if (!is_null($telact->father_id)) { + $rel = new FatherRelation; + $add = [ + 'father_id' => $telact->father_id, + 'child_id' => $child->id, + 'hire_at' => date('Y-m-d H:i:s', time()), + ]; + + $rel->fill($add); + $rel->push(); + } + $telact->delete(); // メールを送ります。 diff --git a/backend/app/Models/TelActivation.php b/backend/app/Models/TelActivation.php index 3902d68e..24b517dd 100644 --- a/backend/app/Models/TelActivation.php +++ b/backend/app/Models/TelActivation.php @@ -8,5 +8,5 @@ use Illuminate\Database\Eloquent\Model; class TelActivation extends Model { use HasFactory; - protected $fillable = ['type', 'child_id', 'tel', 'token', 'ttl']; + protected $fillable = ['type', 'child_id', 'father_id', 'tel', 'token', 'ttl']; } diff --git a/backend/database/factories/TelActivationFactory.php b/backend/database/factories/TelActivationFactory.php index 74e55410..cf735848 100644 --- a/backend/database/factories/TelActivationFactory.php +++ b/backend/database/factories/TelActivationFactory.php @@ -26,10 +26,13 @@ class TelActivationFactory extends Factory '080'.rand(10000000, 99999999), '090'.rand(10000000, 99999999) ]; + $father_id = rand(0, 10); + if ($father_id == 0) $father_id = null; return [ 'type' => rand(0, 1), 'child_id' => rand(1, 10), + 'father_id' => $father_id, 'tel' => $tel[rand(0, 2)], 'token' => $this->faker->creditCardNumber, 'ttl' => $this->faker->dateTime, diff --git a/backend/database/migrations/2021_08_13_050204_create_tel_activations_table.php b/backend/database/migrations/2021_08_13_050204_create_tel_activations_table.php index 6428ca31..2c7fa5ca 100644 --- a/backend/database/migrations/2021_08_13_050204_create_tel_activations_table.php +++ b/backend/database/migrations/2021_08_13_050204_create_tel_activations_table.php @@ -18,6 +18,8 @@ class CreateTelActivationsTable extends Migration $table->unsignedTinyInteger('type'); $table->unsignedBigInteger('child_id')->nullable(); $table->foreign('child_id')->references('id')->on('children')->onDelete('cascade'); + $table->unsignedBigInteger('father_id')->nullable(); + $table->foreign('father_id')->references('id')->on('fathers')->onDelete('cascade'); $table->string('tel', 11)->unique(); $table->string('token', 100)->unique(); $table->dateTime('ttl'); diff --git a/backend/routes/web.php b/backend/routes/web.php index ca5cb070..be479d13 100644 --- a/backend/routes/web.php +++ b/backend/routes/web.php @@ -70,7 +70,7 @@ Route::get('/unknown-error ', function () { return vie // ---------------------------------------- Child Account ------------------------------------------- // Route::group(['prefix' => 'c-account'], function () { - Route::get('/register-temporary', function(Request $r){ return view('c_account.auth', ['father_id'=>$r->father_id]);}); + Route::get('/register-temporary', function (Request $r) { return view('c_account.auth', [ 'father_id' => $r->father_id ]); }); Route::get('/login', '\App\Http\Controllers\Api\ChildrenController@checkLogin')->name('childrenlogin'); Route::get('/logout', '\App\Http\Controllers\Api\ChildrenController@logout'); Route::get('/withdrawal/complete', function () { return view('c_account.auth'); });