where('id',$s['document_id'])->where('uploaded_by',$s['user_id'])->firstOrFail(); if(($argv[1]??'')==='restore')DB::table('documents')->where('id',$doc->id)->update(['deleted_at'=>null]);else{if($doc->deleted_at)throw new RuntimeException('Already unavailable');DB::table('documents')->where('id',$doc->id)->update(['deleted_at'=>now()]);} echo json_encode(['synthetic_document_only'=>true,'restored'=>($argv[1]??'')==='restore']);