「と紐づく子を削除したにも関わらず、ミーティングと子のリレーションが残り続けてしまう。」
このコミットが含まれているのは:
コミット
f95270d6e0
|
@ -5,6 +5,7 @@ namespace App\Http\Controllers\Api;
|
|||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use App\Models\Child;
|
||||
|
@ -99,10 +100,22 @@ class FatherRelationsController extends Controller {
|
|||
}
|
||||
|
||||
try {
|
||||
FatherRelation::where('father_id', session()->get('fathers')['id'])->where('child_id', $child_id)->delete();
|
||||
DB::beginTransaction();
|
||||
|
||||
$rel = FatherRelation::where('father_id', session()->get('fathers')['id'])->where('child_id', (int)$child_id);
|
||||
|
||||
foreach (Meeting::where('father_id', session()->get('fathers')['id'])->get() as $m) {
|
||||
$apr = MeetingApprovals::where('child_id', (int)$child_id)->where('meeting_id', $m->id);
|
||||
$apr->delete();
|
||||
}
|
||||
|
||||
$rel->delete();
|
||||
|
||||
DB::commit();
|
||||
} catch (\Throwable $e) {
|
||||
// 失敗
|
||||
Log::critical($e->getMessage());
|
||||
DB::rollback();
|
||||
return ['status_code' => 400, 'error_messages' => ['子の削除に失敗しました。']];
|
||||
}
|
||||
|
||||
|
|
新しいイシューから参照