「親が子に招待URLを送った場合、子の本登録完了時に招待した親と招待された子が自動でリレーション」
このコミットが含まれているのは:
コミット
60b67762e3
|
@ -64,6 +64,10 @@ class ChildrenController extends Controller {
|
||||||
'ttl' => date('Y-m-d H:i:s', strtotime("8 hour")),
|
'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 {
|
try {
|
||||||
// DBに入ります。
|
// DBに入ります。
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
|
@ -176,6 +180,18 @@ class ChildrenController extends Controller {
|
||||||
$child->fill($insert);
|
$child->fill($insert);
|
||||||
$child->push();
|
$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();
|
$telact->delete();
|
||||||
|
|
||||||
// メールを送ります。
|
// メールを送ります。
|
||||||
|
|
|
@ -8,5 +8,5 @@ use Illuminate\Database\Eloquent\Model;
|
||||||
class TelActivation extends Model
|
class TelActivation extends Model
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
protected $fillable = ['type', 'child_id', 'tel', 'token', 'ttl'];
|
protected $fillable = ['type', 'child_id', 'father_id', 'tel', 'token', 'ttl'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,10 +26,13 @@ class TelActivationFactory extends Factory
|
||||||
'080'.rand(10000000, 99999999),
|
'080'.rand(10000000, 99999999),
|
||||||
'090'.rand(10000000, 99999999)
|
'090'.rand(10000000, 99999999)
|
||||||
];
|
];
|
||||||
|
$father_id = rand(0, 10);
|
||||||
|
if ($father_id == 0) $father_id = null;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'type' => rand(0, 1),
|
'type' => rand(0, 1),
|
||||||
'child_id' => rand(1, 10),
|
'child_id' => rand(1, 10),
|
||||||
|
'father_id' => $father_id,
|
||||||
'tel' => $tel[rand(0, 2)],
|
'tel' => $tel[rand(0, 2)],
|
||||||
'token' => $this->faker->creditCardNumber,
|
'token' => $this->faker->creditCardNumber,
|
||||||
'ttl' => $this->faker->dateTime,
|
'ttl' => $this->faker->dateTime,
|
||||||
|
|
|
@ -18,6 +18,8 @@ class CreateTelActivationsTable extends Migration
|
||||||
$table->unsignedTinyInteger('type');
|
$table->unsignedTinyInteger('type');
|
||||||
$table->unsignedBigInteger('child_id')->nullable();
|
$table->unsignedBigInteger('child_id')->nullable();
|
||||||
$table->foreign('child_id')->references('id')->on('children')->onDelete('cascade');
|
$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('tel', 11)->unique();
|
||||||
$table->string('token', 100)->unique();
|
$table->string('token', 100)->unique();
|
||||||
$table->dateTime('ttl');
|
$table->dateTime('ttl');
|
||||||
|
|
|
@ -70,7 +70,7 @@ Route::get('/unknown-error ', function () { return vie
|
||||||
|
|
||||||
// ---------------------------------------- Child Account ------------------------------------------- //
|
// ---------------------------------------- Child Account ------------------------------------------- //
|
||||||
Route::group(['prefix' => 'c-account'], function () {
|
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('/login', '\App\Http\Controllers\Api\ChildrenController@checkLogin')->name('childrenlogin');
|
||||||
Route::get('/logout', '\App\Http\Controllers\Api\ChildrenController@logout');
|
Route::get('/logout', '\App\Http\Controllers\Api\ChildrenController@logout');
|
||||||
Route::get('/withdrawal/complete', function () { return view('c_account.auth'); });
|
Route::get('/withdrawal/complete', function () { return view('c_account.auth'); });
|
||||||
|
|
新しいイシューから参照